'use strict';
/* jshint expr:true */

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 = 'none';
    var result = karmaConf(model);
    result.should.match(/conf\.paths\.src, '[^\s]*\.js'/);

    model.props.jsPreprocessor.key = 'coffee';
    result = karmaConf(model);
    result.should.match(/conf\.paths\.tmp, '\/serve[^\s]*\.js'/);

    model.props.jsPreprocessor.key = 'babel';
    result = karmaConf(model);
    result.should.match(/conf\.paths\.tmp, '\/serve\/app\/index\.js/);
  });

  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 = 'none';
    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 = 'none';
    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'/);
  });

});

@@ -681,32 +681,99 @@
 rmaConf(model);%0A
+    result.should.match(/conf%5C.paths%5C.src, '%5B%5E%5Cs%5D*%5C.module%5C.js'/);%0A
     result.shoul
@@ -807,32 +807,32 @@
 '%5B%5E%5Cs%5D*%5C.js'/);%0A
-
 %0A    model.props
@@ -886,32 +886,106 @@
 rmaConf(model);%0A
+    result.should.match(/conf%5C.paths%5C.tmp, '%5C/serve%5B%5E%5Cs%5D*%5C.module%5C.js'/);%0A
     result.shoul
@@ -1104,32 +1104,32 @@
 rmaConf(model);%0A
-
     result.shoul
@@ -1177,16 +1177,24 @@
 /index%5C.
+module%5C.
 js/);%0A  

Fix test for template karma-conf