diff --git a/test/function/allows-external-modules-from-nested-module/_config.js b/test/function/allows-external-modules-from-nested-module/_config.js index 918a11a..d0c980e 100644 --- a/test/function/allows-external-modules-from-nested-module/_config.js +++ b/test/function/allows-external-modules-from-nested-module/_config.js @@ -1,3 +1,6 @@ module.exports = { - description: 'imports external modules from nested internal modules' + description: 'imports external modules from nested internal modules', + options: { + external: [ 'path' ] + } }; diff --git a/test/function/custom-external-resolver-async/_config.js b/test/function/custom-external-resolver-async/_config.js new file mode 100644 index 0000000..34faf37 --- /dev/null +++ b/test/function/custom-external-resolver-async/_config.js @@ -0,0 +1,15 @@ +var path = require( 'path' ); +var assert = require( 'assert' ); +var Promise = require( 'sander' ).Promise; + +module.exports = { + description: 'uses a custom external path resolver (asynchronous)', + options: { + resolveExternal: function ( id, importer, options ) { + return Promise.resolve( path.resolve( __dirname, 'js_modules', id + '.js' ) ); + } + }, + exports: function ( exports ) { + assert.ok( exports.success ); + } +}; diff --git a/test/function/custom-external-resolver-async/js_modules/external.js b/test/function/custom-external-resolver-async/js_modules/external.js new file mode 100644 index 0000000..c1547ab --- /dev/null +++ b/test/function/custom-external-resolver-async/js_modules/external.js @@ -0,0 +1 @@ +export default { isExternal: true }; diff --git a/test/function/custom-external-resolver-async/main.js b/test/function/custom-external-resolver-async/main.js new file mode 100644 index 0000000..32214bd --- /dev/null +++ b/test/function/custom-external-resolver-async/main.js @@ -0,0 +1,3 @@ +import external from 'external'; + +export default { success: external.isExternal }; diff --git a/test/function/custom-external-resolver-sync/_config.js b/test/function/custom-external-resolver-sync/_config.js new file mode 100644 index 0000000..2cf6de7 --- /dev/null +++ b/test/function/custom-external-resolver-sync/_config.js @@ -0,0 +1,14 @@ +var path = require( 'path' ); +var assert = require( 'assert' ); + +module.exports = { + description: 'uses a custom external path resolver (synchronous)', + options: { + resolveExternal: function ( id, importer, options ) { + return path.resolve( __dirname, 'js_modules', id + '.js' ); + } + }, + exports: function ( exports ) { + assert.ok( exports.success ); + } +}; diff --git a/test/function/custom-external-resolver-sync/js_modules/external.js b/test/function/custom-external-resolver-sync/js_modules/external.js new file mode 100644 index 0000000..c1547ab --- /dev/null +++ b/test/function/custom-external-resolver-sync/js_modules/external.js @@ -0,0 +1 @@ +export default { isExternal: true }; diff --git a/test/function/custom-external-resolver-sync/main.js b/test/function/custom-external-resolver-sync/main.js new file mode 100644 index 0000000..32214bd --- /dev/null +++ b/test/function/custom-external-resolver-sync/main.js @@ -0,0 +1,3 @@ +import external from 'external'; + +export default { success: external.isExternal }; diff --git a/test/function/import-default-from-external/_config.js b/test/function/import-default-from-external/_config.js index d2d3885..98651b7 100644 --- a/test/function/import-default-from-external/_config.js +++ b/test/function/import-default-from-external/_config.js @@ -1,3 +1,6 @@ module.exports = { - description: 'imports default from external module' -}; \ No newline at end of file + description: 'imports default from external module', + options: { + external: [ 'path' ] + } +}; diff --git a/test/function/import-named-from-external/_config.js b/test/function/import-named-from-external/_config.js index 243412e..cab932b 100644 --- a/test/function/import-named-from-external/_config.js +++ b/test/function/import-named-from-external/_config.js @@ -1,3 +1,6 @@ module.exports = { - description: 'imports names from an external module' -}; \ No newline at end of file + description: 'imports names from an external module', + options: { + external: [ 'path' ] + } +}; diff --git a/test/function/import-namespace-from-external-module-renamed/_config.js b/test/function/import-namespace-from-external-module-renamed/_config.js index 86394b3..4cb00de 100644 --- a/test/function/import-namespace-from-external-module-renamed/_config.js +++ b/test/function/import-namespace-from-external-module-renamed/_config.js @@ -1,3 +1,6 @@ module.exports = { - description: 'imports a namespace from an external module and renames it' + description: 'imports a namespace from an external module and renames it', + options: { + external: [ 'path' ] + } }; diff --git a/test/function/import-namespace-from-external-module/_config.js b/test/function/import-namespace-from-external-module/_config.js index f107139..3704e5c 100644 --- a/test/function/import-namespace-from-external-module/_config.js +++ b/test/function/import-namespace-from-external-module/_config.js @@ -1,3 +1,6 @@ module.exports = { - description: 'imports a namespace from an external module' -}; \ No newline at end of file + description: 'imports a namespace from an external module', + options: { + external: [ 'path' ] + } +}; diff --git a/test/function/imports-are-deconflicted-b/_config.js b/test/function/imports-are-deconflicted-b/_config.js index a7c1041..eceba93 100644 --- a/test/function/imports-are-deconflicted-b/_config.js +++ b/test/function/imports-are-deconflicted-b/_config.js @@ -1,3 +1,6 @@ module.exports = { - description: 'deconflicts imports (redux)' + description: 'deconflicts imports (redux)', + options: { + external: [ 'path' ] + } }; diff --git a/test/function/imports-are-deconflicted/_config.js b/test/function/imports-are-deconflicted/_config.js index 49dbfd8..345f6b8 100644 --- a/test/function/imports-are-deconflicted/_config.js +++ b/test/function/imports-are-deconflicted/_config.js @@ -1,3 +1,6 @@ module.exports = { - description: 'deconflicts imports' + description: 'deconflicts imports', + options: { + external: [ 'path' ] + } }; diff --git a/test/function/legal-import-modification/_config.js b/test/function/legal-import-modification/_config.js new file mode 100644 index 0000000..3792857 --- /dev/null +++ b/test/function/legal-import-modification/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'assigning to properties of imported bindings is permitted' +}; diff --git a/test/function/legal-import-modification/foo.js b/test/function/legal-import-modification/foo.js new file mode 100644 index 0000000..ff8b4c5 --- /dev/null +++ b/test/function/legal-import-modification/foo.js @@ -0,0 +1 @@ +export default {}; diff --git a/test/function/legal-import-modification/main.js b/test/function/legal-import-modification/main.js new file mode 100644 index 0000000..455d804 --- /dev/null +++ b/test/function/legal-import-modification/main.js @@ -0,0 +1,5 @@ +import foo from './foo'; + +foo.modified = true; + +export default foo; diff --git a/test/function/shadowed-external-export/_config.js b/test/function/shadowed-external-export/_config.js index b39af37..2a744dc 100644 --- a/test/function/shadowed-external-export/_config.js +++ b/test/function/shadowed-external-export/_config.js @@ -1,3 +1,6 @@ module.exports = { - description: 'external modules are not shadowed' + description: 'external modules are not shadowed', + options: { + external: [ 'path' ] + } }; diff --git a/test/function/transformer-multiple/_config.js b/test/function/transformer-multiple/_config.js new file mode 100644 index 0000000..34ddbf7 --- /dev/null +++ b/test/function/transformer-multiple/_config.js @@ -0,0 +1,21 @@ +var assert = require( 'assert' ); + +module.exports = { + description: 'accepts multiple transformer functions', + options: { + transform: [ + function ( code, path ) { + return code.replace( /MAGIC_NUMBER/g, 3 ); + }, + + function ( code, path ) { + return code.replace( /\d+/g, function ( match ) { + return 2 * +match; + }); + } + ] + }, + exports: function ( exports ) { + assert.equal( exports.magicNumber, 6 ); + } +} diff --git a/test/function/transformer-multiple/foo.js b/test/function/transformer-multiple/foo.js new file mode 100644 index 0000000..119481e --- /dev/null +++ b/test/function/transformer-multiple/foo.js @@ -0,0 +1 @@ +export default MAGIC_NUMBER; diff --git a/test/function/transformer-multiple/main.js b/test/function/transformer-multiple/main.js new file mode 100644 index 0000000..0fb821d --- /dev/null +++ b/test/function/transformer-multiple/main.js @@ -0,0 +1,3 @@ +import foo from './foo'; + +export var magicNumber = foo; diff --git a/test/function/transformer-single/_config.js b/test/function/transformer-single/_config.js new file mode 100644 index 0000000..4cf7a76 --- /dev/null +++ b/test/function/transformer-single/_config.js @@ -0,0 +1,13 @@ +var assert = require( 'assert' ); + +module.exports = { + description: 'accepts a single transformer function', + options: { + transform: function ( code, path ) { + return code.replace( /MAGIC_NUMBER/g, 3 ); + } + }, + exports: function ( exports ) { + assert.equal( exports.magicNumber, 3 ); + } +} diff --git a/test/function/transformer-single/foo.js b/test/function/transformer-single/foo.js new file mode 100644 index 0000000..119481e --- /dev/null +++ b/test/function/transformer-single/foo.js @@ -0,0 +1 @@ +export default MAGIC_NUMBER; diff --git a/test/function/transformer-single/main.js b/test/function/transformer-single/main.js new file mode 100644 index 0000000..0fb821d --- /dev/null +++ b/test/function/transformer-single/main.js @@ -0,0 +1,3 @@ +import foo from './foo'; + +export var magicNumber = foo;