Skip to content

Commit

Permalink
add more testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Oct 13, 2021
1 parent 2515eea commit 4130dc5
Showing 1 changed file with 12 additions and 8 deletions.
Expand Up @@ -26,26 +26,30 @@ describe("shouldTransform", () => {
"(function a({a}) {})",
"(function a(...a) {})",
"(function a([a = 1]) {})",
"(function a(b, { a: [,...a] }) {})",
];

const negativeCases = [
"(function () {})",
"(function a() {})",
"(function a(a) {})",
"(function a() { var a })",
"(function b([a]) { var a })",
"(function b([a]) { function a() {} })",
"(function a(x = a) {})",
"(function a() { var { a } = {}; })",
"(function b([a]) { var { a } = {}; })",
"(function a({ [a]: b }) {})",
];

describe("default parser options", () => {
test.each(positiveCases)("shouldTransform(%p) should return 'a'", input => {
describe("the following cases should be transformed", () => {
test.each(positiveCases)("%p", input => {
expect(shouldTransform(getPath(input))).toBe("a");
});
test.each(negativeCases)(
"shouldTransform(in %p) should return false",
input => {
expect(shouldTransform(getPath(input))).toBe(false);
},
);
});
describe("the following cases should not be transformed", () => {
test.each(negativeCases)("%p", input => {
expect(shouldTransform(getPath(input))).toBe(false);
});
});
});

0 comments on commit 4130dc5

Please sign in to comment.