Skip to content

Commit

Permalink
Add failing tests for inner scope variable defined verification
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Feb 20, 2019
1 parent 223b1c9 commit d07d960
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/babel-plugin-import-jsx-pragma/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,21 @@ describe( 'babel-plugin-import-jsx-pragma', () => {
expect( string ).toBe( 'import { createElement } from "@wordpress/element";\n' + original );
} );

it( 'does nothing if the scope variable is already defined when using custom options', () => {
it( 'does nothing if the outer scope variable is already defined when using custom options', () => {
const original = 'const {\n createElement\n} = wp.element;\nlet foo = <bar />;';
const string = getTransformedCode( original, {
scopeVariable: 'createElement',
} );

expect( string ).toBe( original );
} );

it( 'does nothing if the inner scope variable is already defined when using custom options', () => {
const original = '(function () {\n const {\n createElement\n } = wp.element;\n let foo = <bar />;\n})();';
const string = getTransformedCode( original, {
scopeVariable: 'createElement',
} );

expect( string ).toBe( original );
} );
} );

0 comments on commit d07d960

Please sign in to comment.