Browse Source

update tests

better-aggressive
Rich-Harris 9 years ago
parent
commit
7d7317e094
  1. 16
      test/function/export-default-anonymous-function/_config.js
  2. 18
      test/function/transformer-multiple/_config.js
  3. 8
      test/function/transformer-single/_config.js
  4. 30
      test/sourcemaps/transforms/_config.js

16
test/function/export-default-anonymous-function/_config.js

@ -4,12 +4,14 @@ var path = require( 'path' );
module.exports = {
description: 'exports an anonymous function with custom ID resolver', // yeah, this is a real edge case
options: {
resolveId: function ( importee, importer ) {
return path.basename( importee ).replace( /\..+/, '' );
},
load: function ( id ) {
console.log( 'id', id )
return fs.readFileSync( path.join( __dirname, id + '.js' ), 'utf-8' );
}
plugins: [{
resolveId: function ( importee, importer ) {
return path.basename( importee ).replace( /\..+/, '' );
},
load: function ( id ) {
console.log( 'id', id )
return fs.readFileSync( path.join( __dirname, id + '.js' ), 'utf-8' );
}
}]
}
};

18
test/function/transformer-multiple/_config.js

@ -3,15 +3,19 @@ var assert = require( 'assert' );
module.exports = {
description: 'accepts multiple transformer functions',
options: {
transform: [
function ( code, path ) {
return code.replace( /MAGIC_NUMBER/g, 3 );
plugins: [
{
transform: function ( code, path ) {
return code.replace( /MAGIC_NUMBER/g, 3 );
}
},
function ( code, path ) {
return code.replace( /\d+/g, function ( match ) {
return 2 * +match;
});
{
transform: function ( code, path ) {
return code.replace( /\d+/g, function ( match ) {
return 2 * +match;
});
}
}
]
},

8
test/function/transformer-single/_config.js

@ -3,9 +3,11 @@ var assert = require( 'assert' );
module.exports = {
description: 'accepts a single transformer function',
options: {
transform: function ( code, path ) {
return code.replace( /MAGIC_NUMBER/g, 3 );
}
plugins: [{
transform: function ( code, path ) {
return code.replace( /MAGIC_NUMBER/g, 3 );
}
}]
},
exports: function ( exports ) {
assert.equal( exports.magicNumber, 3 );

30
test/sourcemaps/transforms/_config.js

@ -7,22 +7,26 @@ var SourceMapConsumer = require( 'source-map' ).SourceMapConsumer;
module.exports = {
description: 'preserves sourcemap chains when transforming',
options: {
transform: [
function ( source, id ) {
return babel.transform( source, {
blacklist: [ 'es6.modules' ],
sourceMap: true
});
plugins: [
{
transform: function ( source, id ) {
return babel.transform( source, {
blacklist: [ 'es6.modules' ],
sourceMap: true
});
}
},
function ( source, id ) {
var s = new MagicString( source );
s.append( '\nassert.equal( 1 + 1, 2 );\nassert.equal( 2 + 2, 4 );' );
{
transform: function ( source, id ) {
var s = new MagicString( source );
s.append( '\nassert.equal( 1 + 1, 2 );\nassert.equal( 2 + 2, 4 );' );
return {
code: s.toString(),
map: s.generateMap({ hires: true })
};
return {
code: s.toString(),
map: s.generateMap({ hires: true })
};
}
}
]
},

Loading…
Cancel
Save