Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Update tests to cover ignoreGlobal
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrage committed Aug 11, 2016
1 parent 736f542 commit 7e557a7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions test/samples/ignore-global/firstpass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export var immediate = typeof global.setImmediate === 'function' ?
global.setImmediate : global.setTimeout;
4 changes: 4 additions & 0 deletions test/samples/ignore-global/identifier.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// require (firstpass)

export var immediate = typeof global.setImmediate === 'function' ?
global.setImmediate : global.setTimeout;
7 changes: 3 additions & 4 deletions test/samples/ignore-global/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export var immediate = typeof global.setImmediate === 'function' ?
global.setImmediate : global.setTimeout;

// firstpass: require
export { immediate as immediate1 } from './firstpass';
export { immediate as immediate2 } from './identifier';
export { immediate as immediate3 } from './this';
6 changes: 6 additions & 0 deletions test/samples/ignore-global/this.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// require (firstpass)

// "this" will be rewritten with "undefined" by rollup
export var immediate = typeof this === 'undefined' ?
null : typeof this.setImmediate === 'function' ?
this.setImmediate : this.setTimeout;
6 changes: 5 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,11 @@ describe( 'rollup-plugin-commonjs', () => {
format: 'cjs'
});

assert.equal( global.setImmediate, executeBundle( bundle ).immediate, generated.code );
const bundleExports = executeBundle( bundle )

assert.equal( bundleExports.immediate1, global.setImmediate, generated.code );
assert.equal( bundleExports.immediate2, global.setImmediate, generated.code );
assert.equal( bundleExports.immediate3, null, generated.code );
});
});

Expand Down

0 comments on commit 7e557a7

Please sign in to comment.