From 7d7317e094d641d7a64fcc865ee0d7b71110f67b Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Sun, 25 Oct 2015 16:37:37 -0400 Subject: [PATCH] update tests --- .../_config.js | 16 +++++----- test/function/transformer-multiple/_config.js | 18 ++++++----- test/function/transformer-single/_config.js | 8 +++-- test/sourcemaps/transforms/_config.js | 30 +++++++++++-------- 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/test/function/export-default-anonymous-function/_config.js b/test/function/export-default-anonymous-function/_config.js index 223ab15..3cb321f 100644 --- a/test/function/export-default-anonymous-function/_config.js +++ b/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' ); + } + }] } }; diff --git a/test/function/transformer-multiple/_config.js b/test/function/transformer-multiple/_config.js index 34ddbf7..e9aab9a 100644 --- a/test/function/transformer-multiple/_config.js +++ b/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; + }); + } } ] }, diff --git a/test/function/transformer-single/_config.js b/test/function/transformer-single/_config.js index 4cf7a76..93a1364 100644 --- a/test/function/transformer-single/_config.js +++ b/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 ); diff --git a/test/sourcemaps/transforms/_config.js b/test/sourcemaps/transforms/_config.js index e5c230f..b76a885 100644 --- a/test/sourcemaps/transforms/_config.js +++ b/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 }) + }; + } } ] },