From 74641f50b4137064bb89bba6d06a6f683712691e Mon Sep 17 00:00:00 2001 From: Pionxzh Date: Thu, 28 Mar 2024 07:20:06 +0800 Subject: [PATCH] test: add test cases for `renameFunctionParameters.spec` --- .../renameFunctionParameters.spec.ts | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/packages/ast-utils/__tests__/renameFunctionParameters.spec.ts b/packages/ast-utils/__tests__/renameFunctionParameters.spec.ts index 072dd054..00147f0a 100644 --- a/packages/ast-utils/__tests__/renameFunctionParameters.spec.ts +++ b/packages/ast-utils/__tests__/renameFunctionParameters.spec.ts @@ -55,6 +55,64 @@ function foo(c, d) { `, ) +inlineTest('should rename function parameters #2', + ` +function foo(a, b) { + function a() { + return a + b; + } + + return a + b; +} +`, + ` +function foo(c, d) { + function a() { + return a + d; + } + + return a + d; +} +`, +) + +inlineTest('should rename function parameters #3', + ` +function z(e, t, n) { + "use strict"; + !(function e() { + if ( + "undefined" != typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && + "function" == typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE + ) + try { + __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e); + } catch (e) { + console.error(e); + } + })(); + e.exports = n(48); +} +`, + ` +function z(c, d, xx) { + "use strict"; + !(function e() { + if ( + "undefined" != typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && + "function" == typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE + ) + try { + __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e); + } catch (e) { + console.error(e); + } + })(); + c.exports = xx(48); +} +`, +) + inlineTest('Class', ` function foo(a, b, x, z) {