Skip to content

Commit

Permalink
Merge pull request #770 from Swiip/premarkup-in-karma
Browse files Browse the repository at this point in the history
Load preprocessed markups in karma tests, fix #731
  • Loading branch information
Mehdy Dara committed Sep 14, 2015
2 parents 21ec33c + 197313b commit b7a50ca
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
19 changes: 15 additions & 4 deletions app/templates/_karma.conf.js
Expand Up @@ -6,6 +6,15 @@ var conf = require('./gulp/conf');
var _ = require('lodash');
var wiredep = require('wiredep');

var pathSrcHtml = [
<% if (props.htmlPreprocessor.key === 'noHtmlPrepro') { -%>
path.join(conf.paths.src, '/**/*.html')
<% } else { -%>
path.join(conf.paths.tmp, '/serve/app/**/*.html'),
path.join(conf.paths.src, '/**/*.html')
<% } -%>
];

function listFiles() {
var wiredepOptions = _.extend({}, conf.wiredep, {
dependencies: true,
Expand All @@ -27,8 +36,8 @@ function listFiles() {
<% } else { -%>
path.join(conf.paths.tmp, '/serve/app/index.module.js'),
<% } -%>
path.join(conf.paths.src, '/**/*.html')
]);
])
.concat(pathSrcHtml);
}

module.exports = function(config) {
Expand Down Expand Up @@ -88,8 +97,10 @@ module.exports = function(config) {
};

var preprocessors = {};
var pathSrcHtml = path.join(conf.paths.src, '/**/*.html');
preprocessors[pathSrcHtml] = ['ng-html2js'];

pathSrcHtml.forEach(function(path) {
preprocessors[path] = ['ng-html2js'];
});

<% if (props.jsPreprocessor.key === 'noJsPrepro') { -%>
var pathSrcJs = path.join(conf.paths.src, '/**/!(*.spec).js');
Expand Down
12 changes: 12 additions & 0 deletions test/template/test-karma-conf.js
Expand Up @@ -42,6 +42,18 @@ describe('gulp-angular karma.conf template', function () {
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);
Expand Down

0 comments on commit b7a50ca

Please sign in to comment.