Socket
Socket
Sign inDemoInstall

ember-sinon-qunit-codemod

Package Overview
Dependencies
382
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

transforms/ember-sinon-qunit/__testfixtures__/sample-test-with-sandbox-reference.input.js

2

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc