-
Notifications
You must be signed in to change notification settings - Fork 661
/
Copy pathtest-scripts.js
89 lines (76 loc) · 3.13 KB
/
test-scripts.js
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
var chai = require('chai');
var sinonChai = require('sinon-chai');
chai.should();
chai.use(sinonChai);
var templateTools = require('../template-tools');
var mockModel = require('./mock-model');
describe('gulp-angular scripts template', function () {
var scripts;
var model;
before(function () {
return templateTools.load('gulp/_scripts.js')
.then(function (templateModule) {
scripts = templateModule;
});
});
beforeEach(function () {
model = mockModel();
});
it('should add the right js preprocessor process', function () {
model.props.jsPreprocessor.key = 'noJsPrepro';
var result = scripts(model);
result.should.not.match(/babel/);
result.should.not.match(/coffee/);
result.should.not.match(/traceur/);
result.should.not.match(/typescript/);
model.props.jsPreprocessor.key = 'coffee';
model.props.jsPreprocessor.extension = 'coffee';
result = scripts(model);
result.should.match(/gulp\.src.*conf\.paths\.src, '.*\.coffee'/);
result.should.match(/\$\.coffee\(/);
result.should.match(/\$\.coffeelint\(/);
result.should.not.match(/babel/);
result.should.not.match(/traceur/);
result.should.not.match(/typescript/);
model.props.jsPreprocessor.key = 'typescript';
model.props.jsPreprocessor.extension = 'ts';
result = scripts(model);
result.should.match(/function webpackWrapper\(watch, test, callback\)/);
result.should.match(/loaders:.*loaders: \['ng-annotate', 'ts-loader'/);
result.should.match(/gulp\.task\('scripts:watch'/);
result.should.not.match(/babel/);
result.should.not.match(/traceur/);
result.should.not.match(/coffee/);
model.props.jsPreprocessor.key = 'babel';
model.props.jsPreprocessor.extension = 'js';
model.props.jsPreprocessor.srcExtension = 'es6';
result = scripts(model);
result.should.match(/function webpackWrapper\(watch, test, callback\)/);
result.should.match(/loaders:.*loaders: \['ng-annotate', 'babel-loader\?presets\[]=es2015'/);
result.should.match(/gulp\.task\('scripts:watch'/);
result.should.not.match(/traceur/);
result.should.not.match(/coffee/);
result.should.not.match(/typescript/);
model.props.jsPreprocessor.key = 'traceur';
model.props.jsPreprocessor.extension = 'js';
model.props.jsPreprocessor.srcExtension = 'es6';
result = scripts(model);
result.should.match(/function webpackWrapper\(watch, test, callback\)/);
result.should.match(/loaders:.*loaders: \['ng-annotate', 'traceur-loader'/);
result.should.match(/gulp\.task\('scripts:watch'/);
result.should.not.match(/babel/);
result.should.not.match(/coffee/);
result.should.not.match(/typescript/);
});
it('should add match to browserSync options when not using a js preprocessor', function () {
model.props.jsPreprocessor.key = 'noJsPrepro';
var result = scripts(model);
result.should.match(/bsOptions\.match/);
});
it('should not add match to browserSync options when using a js preprocessor', function () {
model.props.jsPreprocessor.key = 'babel';
var result = scripts(model);
result.should.not.match(/bsOptions\.match/);
});
});