concat_test.js
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
'use strict';
var grunt = require('grunt');
var comment = require('../tasks/lib/comment').init(grunt);
function getNormalizedFile(filepath) {
return grunt.util.normalizelf(grunt.file.read(filepath));
}
exports.concat = {
default_options: function(test) {
test.expect(1);
var actual = getNormalizedFile('tmp/default_options');
var expected = getNormalizedFile('test/expected/default_options');
test.equal(actual, expected, 'should describe what the default behavior is.');
test.done();
},
custom_options: function(test) {
test.expect(1);
var actual = getNormalizedFile('tmp/custom_options');
var expected = getNormalizedFile('test/expected/custom_options');
test.equal(actual, expected, 'should utilize custom banner, footer and separator.');
test.done();
},
handling_invalid_files: function(test) {
test.expect(1);
var actual = getNormalizedFile('tmp/handling_invalid_files');
var expected = getNormalizedFile('test/expected/handling_invalid_files');
test.equal(actual, expected, 'will have warned, but should not fail.');
test.done();
},
strip_banner: function(test) {
test.expect(7);
var src = getNormalizedFile('test/fixtures/banner.js');
test.equal(comment.stripBanner(src), grunt.util.normalizelf('// Comment\n\n/* Comment */\n'), 'It should strip the top banner.');
test.equal(comment.stripBanner(src, {block: true}), grunt.util.normalizelf('// Comment\n\n/* Comment */\n'), 'It should strip the top banner.');
src = getNormalizedFile('test/fixtures/banner2.js');
test.equal(comment.stripBanner(src), grunt.util.normalizelf('\n/*! SAMPLE\n * BANNER */\n\n// Comment\n\n/* Comment */\n'), 'It should not strip the top banner.');
test.equal(comment.stripBanner(src, {block: true}), grunt.util.normalizelf('// Comment\n\n/* Comment */\n'), 'It should strip the top banner.');
src = getNormalizedFile('test/fixtures/banner3.js');
test.equal(comment.stripBanner(src), grunt.util.normalizelf('\n// This is\n// A sample\n// Banner\n\n// But this is not\n\n/* And neither\n * is this\n */\n'), 'It should not strip the top banner.');
test.equal(comment.stripBanner(src, {block: true}), grunt.util.normalizelf('\n// This is\n// A sample\n// Banner\n\n// But this is not\n\n/* And neither\n * is this\n */\n'), 'It should not strip the top banner.');
test.equal(comment.stripBanner(src, {line: true}), grunt.util.normalizelf('// But this is not\n\n/* And neither\n * is this\n */\n'), 'It should strip the top banner.');
test.done();
},
process_function: function(test) {
test.expect(1);
var actual = getNormalizedFile('tmp/process_function');
var expected = getNormalizedFile('test/expected/process_function');
test.equal(actual, expected, 'should have processed file content.');
test.done();
}
};