Browse Source

update tests

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

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

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

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

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

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

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

10
test/sourcemaps/transforms/_config.js

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

Loading…
Cancel
Save