Browse Source

update tests

better-aggressive
Rich-Harris 9 years ago
parent
commit
a3a2b2b1e6
  1. 1
      test/form/intro-and-outro/_config.js
  2. 6
      test/sourcemaps/basic-support/_config.js
  3. 4
      test/sourcemaps/transforms/_config.js
  4. 8
      test/test.js

1
test/form/intro-and-outro/_config.js

@ -1,5 +1,4 @@
module.exports = {
solo: true,
description: 'adds an intro/outro',
options: {
intro: '/* this is an intro */',

6
test/sourcemaps/basic-support/_config.js

@ -18,7 +18,7 @@ module.exports = {
assert.equal( originalLoc.line, 4 );
assert.equal( originalLoc.column, 0 );
assert.equal( originalLoc.source, 'sourcemaps/basic-support/main.js' );
assert.equal( originalLoc.source, '../main.js' );
// foo.js
generatedLoc = getLocation( code, code.indexOf( "console.log( 'hello from foo.js' )" ) );
@ -26,7 +26,7 @@ module.exports = {
assert.equal( originalLoc.line, 2 );
assert.equal( originalLoc.column, 1 );
assert.equal( originalLoc.source, 'sourcemaps/basic-support/foo.js' );
assert.equal( originalLoc.source, '../foo.js' );
// bar.js
generatedLoc = getLocation( code, code.indexOf( "console.log( 'hello from bar.js' )" ) );
@ -34,6 +34,6 @@ module.exports = {
assert.equal( originalLoc.line, 2 );
assert.equal( originalLoc.column, 1 );
assert.equal( originalLoc.source, 'sourcemaps/basic-support/bar.js' );
assert.equal( originalLoc.source, '../bar.js' );
}
};

4
test/sourcemaps/transforms/_config.js

@ -17,7 +17,7 @@ module.exports = {
function ( source, id ) {
var s = new MagicString( source );
s.prepend( '// this is a comment\n' );
s.append( '\nassert.equal( 1 + 1, 2 );\nassert.equal( 2 + 2, 4 );' );
return {
code: s.toString(),
@ -29,7 +29,7 @@ module.exports = {
test: function ( code, map ) {
var smc = new SourceMapConsumer( map );
var generatedLoc = getLocation( code, code.indexOf( 42 ) );
var generatedLoc = getLocation( code, code.indexOf( '42' ) );
var originalLoc = smc.originalPositionFor( generatedLoc );
assert.ok( /foo/.test( originalLoc.source ) );

8
test/test.js

@ -270,9 +270,11 @@ describe( 'rollup', function () {
describe( dir, function () {
var config = require( SOURCEMAPS + '/' + dir + '/_config' );
var entry = path.resolve( SOURCEMAPS, dir, 'main.js' );
var dest = path.resolve( SOURCEMAPS, dir, '_actual/bundle.js' );
var options = extend( {}, config.options, {
entry: SOURCEMAPS + '/' + dir + '/main.js'
entry: entry
});
PROFILES.forEach( function ( profile ) {
@ -281,9 +283,11 @@ describe( 'rollup', function () {
var options = extend( {}, config.options, {
format: profile.format,
sourceMap: true,
sourceMapFile: path.resolve( __dirname, 'bundle.js' )
dest: dest
});
bundle.write( options );
var result = bundle.generate( options );
config.test( result.code, result.map );
});

Loading…
Cancel
Save