Browse Source

add test of function moduleContext option

legacy-quote-reserved-properties
Rich-Harris 8 years ago
parent
commit
559ef0f343
  1. 8
      test/form/custom-module-context-function/_config.js
  2. 7
      test/form/custom-module-context-function/_expected/amd.js
  3. 5
      test/form/custom-module-context-function/_expected/cjs.js
  4. 3
      test/form/custom-module-context-function/_expected/es.js
  5. 8
      test/form/custom-module-context-function/_expected/iife.js
  6. 11
      test/form/custom-module-context-function/_expected/umd.js
  7. 1
      test/form/custom-module-context-function/foo.js
  8. 2
      test/form/custom-module-context-function/main.js
  9. 2
      test/test.js

8
test/form/custom-module-context-function/_config.js

@ -0,0 +1,8 @@
module.exports = {
description: 'allows custom module-specific context with a function option',
options: {
moduleContext ( id ) {
return /main\.js$/.test( id ) ? 'lolwut' : 'undefined';
}
}
};

7
test/form/custom-module-context-function/_expected/amd.js

@ -0,0 +1,7 @@
define(function () { 'use strict';
undefined.prop = 'nope';
lolwut.prop = '???';
});

5
test/form/custom-module-context-function/_expected/cjs.js

@ -0,0 +1,5 @@
'use strict';
undefined.prop = 'nope';
lolwut.prop = '???';

3
test/form/custom-module-context-function/_expected/es.js

@ -0,0 +1,3 @@
undefined.prop = 'nope';
lolwut.prop = '???';

8
test/form/custom-module-context-function/_expected/iife.js

@ -0,0 +1,8 @@
(function () {
'use strict';
undefined.prop = 'nope';
lolwut.prop = '???';
}());

11
test/form/custom-module-context-function/_expected/umd.js

@ -0,0 +1,11 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
typeof define === 'function' && define.amd ? define(factory) :
(factory());
}(this, (function () { 'use strict';
undefined.prop = 'nope';
lolwut.prop = '???';
})));

1
test/form/custom-module-context-function/foo.js

@ -0,0 +1 @@
this.prop = 'nope';

2
test/form/custom-module-context-function/main.js

@ -0,0 +1,2 @@
import './foo.js';
this.prop = '???';

2
test/test.js

@ -316,6 +316,8 @@ describe( 'rollup', function () {
PROFILES.forEach( profile => {
it( 'generates ' + profile.format, () => {
process.chdir( FORM + '/' + dir );
return createBundle().then( bundle => {
const options = extend( {}, config.options, {
dest: FORM + '/' + dir + '/_actual/' + profile.format + '.js',

Loading…
Cancel
Save