From 4130dc56a1aa5386b692d5589ba4f6ee799c09f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 12 Oct 2021 20:27:33 -0400 Subject: [PATCH] add more testcases --- .../test/util.test.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/babel-plugin-bugfix-webkit-id-destructuring-collision-in-function-expression/test/util.test.js b/packages/babel-plugin-bugfix-webkit-id-destructuring-collision-in-function-expression/test/util.test.js index 30ef0fc9e6d4..597f58fb901f 100644 --- a/packages/babel-plugin-bugfix-webkit-id-destructuring-collision-in-function-expression/test/util.test.js +++ b/packages/babel-plugin-bugfix-webkit-id-destructuring-collision-in-function-expression/test/util.test.js @@ -26,6 +26,7 @@ describe("shouldTransform", () => { "(function a({a}) {})", "(function a(...a) {})", "(function a([a = 1]) {})", + "(function a(b, { a: [,...a] }) {})", ]; const negativeCases = [ @@ -33,19 +34,22 @@ describe("shouldTransform", () => { "(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); + }); }); });