Skip to content

Commit

Permalink
Added interpolation tests -- failing as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
twolfson committed Nov 1, 2012
1 parent dd0d3b5 commit c0c3622
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
32 changes: 21 additions & 11 deletions test/grunt.js
Expand Up @@ -2,19 +2,29 @@ module.exports = function (grunt) {
grunt.file.mkdir('actual');

grunt.initConfig({
'pkg': {
'name': 'grunt-jsmin-sourcemap',
'version': '1.5.0'
},
'jsmin-sourcemap': {
// Compact format -- https://github.com/gruntjs/grunt/blob/master/docs/api.md#thisfile--grunttaskcurrentfile
'actual/compact.min.js': 'test_files/jquery.js',
// Normal format
single: {
// // Compact format -- https://github.com/gruntjs/grunt/blob/master/docs/api.md#thisfile--grunttaskcurrentfile
// 'actual/compact.min.js': 'test_files/jquery.js',
// // Normal format
// single: {
// src: 'test_files/jquery.js',
// dest: 'actual/jquery.min.js',
// destMap: 'actual/jquery.js.map'
// },
// multi: {
// src: ['test_files/jquery.js', 'test_files/underscore.js'],
// dest: 'actual/multi.min.js',
// destMap: 'actual/multi.js.map'
// },
// Package specific interpolation
interpolation: {
src: 'test_files/jquery.js',
dest: 'actual/jquery.min.js',
destMap: 'actual/jquery.js.map'
},
multi: {
src: ['test_files/jquery.js', 'test_files/underscore.js'],
dest: 'actual/multi.min.js',
destMap: 'actual/multi.js.map'
dest: 'actual/interpolate.<%= pkg.name %>-<%= pkg.version %>.min.js',
destMap: 'actual/interpolate.<%= pkg.name %>-<%= pkg.version %>.js.map'
}
},
test: {
Expand Down
14 changes: 14 additions & 0 deletions test/jsmin-sourcemap.test.js
Expand Up @@ -66,6 +66,20 @@ exports['jsmin-sourcemap'] = {
// as well as a sourcemap
test.ok(actualMultiMap, ' generates a source map for multiple files');

// Interpolated file paths
var expectedInterpolate = grunt.file.read('expected/jquery.min.js'),
actualInterpolate = grunt.file.read('actual/interpolate.min.js'),
actualInterpolateMap = grunt.file.read('actual/interpolate.js.map'),
interpolateMapComment = '//@ sourceMappingURL=interpolate.js.map',
interpolateMapDeclarativeExists = actualSingle.indexOf(interpolateMapComment) > -1;

// outputs proper minified code
test.strictEqual(actualInterpolate, expectedInterpolate, ' properly minifies a interpolated file');
// which points to the map file
test.ok(interpolateMapDeclarativeExists, ' points to the proper map location for the interpolated file');
// as well as a sourcemap
test.ok(actualInterpolateMap, ' generates a source map for at the interpolated location');

test.done();
}
};

0 comments on commit c0c3622

Please sign in to comment.