Browse Source

more tests

better-aggressive
Rich-Harris 9 years ago
parent
commit
e07c67b530
  1. 19
      test/function/custom-loaders/_config.js
  2. 1
      test/function/custom-loaders/bar.js
  3. 1
      test/function/custom-loaders/baz.js
  4. 1
      test/function/custom-loaders/foo.js
  5. 7
      test/function/custom-loaders/main.js
  6. 21
      test/function/custom-path-resolver-plural-b/_config.js

19
test/function/custom-loaders/_config.js

@ -0,0 +1,19 @@
var fs = require( 'fs' );
module.exports = {
description: 'uses custom loaders, falling back to default',
options: {
load: [
function ( id ) {
if ( /foo\.js/.test( id ) ) {
return fs.readFileSync( id, 'utf-8' ).replace( '@', 1 );
}
},
function ( id ) {
if ( /bar\.js/.test( id ) ) {
return fs.readFileSync( id, 'utf-8' ).replace( '@', 2 );
}
}
]
}
};

1
test/function/custom-loaders/bar.js

@ -0,0 +1 @@
export default '@';

1
test/function/custom-loaders/baz.js

@ -0,0 +1 @@
export default '@';

1
test/function/custom-loaders/foo.js

@ -0,0 +1 @@
export default '@';

7
test/function/custom-loaders/main.js

@ -0,0 +1,7 @@
import foo from './foo';
import bar from './bar';
import baz from './baz';
assert.equal( foo, '1' );
assert.equal( bar, '2' );
assert.equal( baz, '@' );

21
test/function/custom-path-resolver-plural-b/_config.js

@ -0,0 +1,21 @@
var assert = require( 'assert' );
module.exports = {
description: 'resolver error is not caught',
options: {
resolveId: [
function () {
throw new Error( 'nope' );
},
function ( importee, importer ) {
return 'main';
}
],
load: function ( id ) {
if ( id === 'main' ) return 'assert.ok( false );'
}
},
error: function ( err ) {
assert.equal( err.message, 'nope' );
}
};
Loading…
Cancel
Save