Add translations to Karma specs

* Added a task to Gruntfile to use website/src/i18n.js to generate a small JS file to be loaded in Karma env which sets window.env.translations to the i18n.translations['en'].

* Added new Grunt task to build:dev

* Updated Karma specs to reenable testing where possible, updating comments where not.
This commit is contained in:
Kevin Gisi
2015-03-22 09:06:37 -04:00
parent f41933b7a1
commit 09b6401794
8 changed files with 29 additions and 18 deletions

View File

@@ -154,8 +154,8 @@ module.exports = function(grunt) {
fileNameFormat: '${name}-${hash}.${ext}'
},
src: [
'website/build/*.js',
'website/build/*.css',
'website/build/*.js',
'website/build/*.css',
'website/build/favicon.ico',
'website/build/common/dist/sprites/*.png',
'website/build/common/img/sprites/backer-only/*.gif',
@@ -166,7 +166,7 @@ module.exports = function(grunt) {
}
},
nodemon: {
nodemon: {
dev: {
script: '<%= pkg.main %>'
}
@@ -202,7 +202,7 @@ module.exports = function(grunt) {
_.each(files[key].js, function(val){
var path = "./";
if( val.indexOf('common/') == -1)
if( val.indexOf('common/') == -1)
path = './website/public/';
js.push(path + val);
});
@@ -213,7 +213,7 @@ module.exports = function(grunt) {
var path = "./";
if( val.indexOf('common/') == -1) {
path = (val == 'app.css' || val == 'static.css') ? './website/build/' : './website/public/';
}
}
css.push(path + val)
});
@@ -230,10 +230,19 @@ module.exports = function(grunt) {
// Register tasks.
grunt.registerTask('compile:sprites', ['clean:sprite', 'sprite', 'cssmin']);
grunt.registerTask('build:prod', ['loadManifestFiles', 'clean:build', 'browserify', 'uglify', 'stylus', 'cssmin', 'copy:build', 'hashres']);
grunt.registerTask('build:dev', ['browserify', 'stylus']);
grunt.registerTask('build:dev', ['browserify', 'stylus', 'test:prepare:translations']);
grunt.registerTask('run:dev', [ 'build:dev', 'concurrent' ]);
grunt.registerTask('test:prepare:translations', function() {
require('coffee-script');
var i18n = require('./website/src/i18n'),
fs = require('fs');
fs.writeFileSync('test/spec/translations.js',
"if(!window.env) window.env = {};\n" +
"window.env.translations = " + JSON.stringify(i18n.translations['en']) + ';');
});
if(process.env.NODE_ENV == 'production')
grunt.registerTask('default', ['build:prod']);
else