-
Notifications
You must be signed in to change notification settings - Fork 667
/
test-karma-conf.js
90 lines (73 loc) · 3.18 KB
/
test-karma-conf.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
90
'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 karma.conf template', function () {
var karmaConf, model;
before(function() {
return templateTools.load('_karma.conf.js')
.then(function(templateModule) {
karmaConf = templateModule;
});
});
beforeEach(function() {
model = mockModel();
});
it('should add files in list files for each js preprocessors', function() {
model.props.jsPreprocessor.key = 'noJsPrepro';
var result = karmaConf(model);
result.should.match(/conf\.paths\.src, '[^\s]*\.module\.js'/);
result.should.match(/conf\.paths\.src, '[^\s]*\.js'/);
model.props.jsPreprocessor.key = 'coffee';
result = karmaConf(model);
result.should.match(/conf\.paths\.tmp, '\/serve[^\s]*\.module\.js'/);
result.should.match(/conf\.paths\.tmp, '\/serve[^\s]*\.js'/);
model.props.jsPreprocessor.key = 'typescript';
result = karmaConf(model);
result.should.match(/conf\.paths\.tmp, '\/serve\/app\/index\.module\.js/);
model.props.jsPreprocessor.key = 'babel';
result = karmaConf(model);
result.should.match(/conf\.paths\.tmp, '\/serve\/app\/index\.module\.js/);
});
it('should add files in list files for each html preprocessors', function() {
model.props.htmlPreprocessor.key = 'noHtmlPrepro';
var result = karmaConf(model);
result.should.match(/conf\.paths\.src, '[^\s]*\.html'/);
result.should.not.match(/conf\.paths\.tmp, '\/serve[^\s]*\.html'/);
model.props.htmlPreprocessor.key = 'jade';
result = karmaConf(model);
result.should.match(/conf\.paths\.src, '[^\s]*\.html'/);
result.should.match(/conf\.paths\.tmp, '\/serve[^\s]*\.html'/);
});
it('should add and configure angular filesort if needed', function() {
model.props.jsPreprocessor.key = 'babel';
var result = karmaConf(model);
result.should.match(/frameworks: \['jasmine'\]/);
result.should.not.match(/'karma-angular-filesort'/);
model.props.jsPreprocessor.key = 'noJsPrepro';
result = karmaConf(model);
result.should.match(/frameworks: \['jasmine', 'angular-filesort'\]/);
result.should.match(/whitelist: \[[^\s]*conf\.paths\.src/);
result.should.match(/'karma-angular-filesort'/);
model.props.jsPreprocessor.key = 'coffee';
result = karmaConf(model);
result.should.match(/frameworks: \['jasmine', 'angular-filesort'\]/);
result.should.match(/whitelist: \[[^\s]*conf\.paths\.tmp/);
result.should.match(/'karma-angular-filesort'/);
});
it('should replace phantom with chrome for traceur', function() {
model.props.jsPreprocessor.key = 'noJsPrepro';
var result = karmaConf(model);
result.should.match(/browsers : \['PhantomJS'\]/);
result.should.match(/'karma-phantomjs-launcher'/);
result.should.not.match(/'karma-chrome-launcher'/);
model.props.jsPreprocessor.key = 'traceur';
result = karmaConf(model);
result.should.match(/browsers : \['Chrome'\]/);
result.should.match(/'karma-chrome-launcher'/);
result.should.not.match(/'karma-phantomjs-launcher'/);
});
});