ember-sinon-qunit-codemod
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "ember-sinon-qunit-codemod", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A codemod for migrating to ember-sinon-qunit V4", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,1 +13,3 @@ import { defineTest } from 'jscodeshift/dist/testUtils'; | ||
defineTest(__dirname, 'transform', {}, 'sample-test-with-setup-sinon-sandbox'); | ||
defineTest(__dirname, 'transform', {}, 'sample-test-with-sandbox-reference'); | ||
defineTest(__dirname, 'transform', {}, 'test-helper-with-sinon-setup'); |
@@ -71,4 +71,9 @@ import { Transform } from 'jscodeshift'; | ||
// If we're in the test helper, setupSinon | ||
if (isTestHelper) { | ||
// If we're in the test helper and we dont already have setupSinon | ||
if ( | ||
isTestHelper && | ||
!root.find(j.ImportDeclaration, p => | ||
p.specifiers.find(specifier => specifier.local.name === 'setupSinon') | ||
).length | ||
) { | ||
root | ||
@@ -105,4 +110,4 @@ .find(j.ImportDeclaration) | ||
const convertThisSandboxToSinon = () => { | ||
const sandboxNodes = root.find(j.MemberExpression, { | ||
const convertSandboxToSinon = () => { | ||
const thisSandboxNodes = root.find(j.MemberExpression, { | ||
object: { type: 'ThisExpression' }, | ||
@@ -114,3 +119,3 @@ property: { name: 'sandbox' } | ||
if ( | ||
sandboxNodes.length > 0 && | ||
thisSandboxNodes.length > 0 && | ||
!root.find(j.ImportDefaultSpecifier, { local: { name: 'sinon' } }).length | ||
@@ -134,3 +139,9 @@ ) { | ||
sandboxNodes.replaceWith(j.identifier('sinon')); | ||
thisSandboxNodes.replaceWith(j.identifier('sinon')); | ||
root.findVariableDeclarators('sandbox').remove(); | ||
root | ||
.find(j.Identifier, { name: 'sandbox' }) | ||
.replaceWith(j.identifier('sinon')); | ||
}; | ||
@@ -167,3 +178,3 @@ | ||
setupSinonTestHelper(); | ||
convertThisSandboxToSinon(); | ||
convertSandboxToSinon(); | ||
removeSinonRestore(); | ||
@@ -170,0 +181,0 @@ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
22051
30
580
0