grunt-contrib-jasmine/test/jasmine_test.js

55 lines
1.6 KiB
JavaScript
Raw Normal View History

2012-11-02 13:03:09 +08:00
'use strict';
2014-06-07 07:33:59 +08:00
var grunt = require('grunt'),
phantomjs = require('grunt-lib-phantomjs').init(grunt),
jasmine = require('../tasks/lib/jasmine.js').init(grunt, phantomjs);
2012-11-02 13:03:09 +08:00
// Majority of test benefit comes from running the task itself.
function runTemplate(src,context) {
var source = grunt.file.read(src);
return grunt.util._.template(source, context);
}
// Just strips whitespace for now. Should do a proper min of everything
// but this is working well enough for now.
function normalize(html) {
return html.replace(/\s*/g,'');
}
2012-11-02 13:03:09 +08:00
exports.jasmine = {
defaultTemplate: function(test) {
test.expect(1);
var context = {
css : ['css/a.css'],
scripts : {
2013-06-16 00:38:39 +08:00
polyfills : ['p1.js'],
jasmine : ['J1.js','J2.js'],
helpers : ['H1.js','H2.js'],
specs : ['SPEC1.js','SPEC2.js'],
src : ['SRC1.js','SRC2.js'],
vendor : ['V1.js','V2.js'],
reporters : ['R1.js'],
2013-11-21 08:46:27 +08:00
boot : ['BOOT.js']
},
temp: 'path/to/temp/folder',
options : {}
};
var actual = runTemplate('./tasks/jasmine/templates/DefaultRunner.tmpl', context);
var expected = grunt.file.read('./test/expected/defaultTemplate.html');
test.equal(normalize(actual),normalize(expected), 'default test runner template');
2014-06-07 07:33:59 +08:00
test.done();
},
fileExpand: function(test) {
var patterns = ['test/fixtures/fileExpand/src/*.js', '!test/fixtures/fileExpand/src/exclude.js']
var expected = ['test/fixtures/fileExpand/src/include.js'];
test.deepEqual(jasmine.getRelativeFileList('', patterns, {}), expected, 'should properly expand file list')
test.done();
2012-11-02 13:03:09 +08:00
}
};