mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 21:57:22 +01:00
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:
21
Gruntfile.js
21
Gruntfile.js
@@ -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
|
||||
|
||||
@@ -34,6 +34,8 @@ module.exports = function(config) {
|
||||
'website/public/bower_components/js-emoji/emoji.js',
|
||||
'common/dist/scripts/habitrpg-shared.js',
|
||||
|
||||
"test/spec/translations.js",
|
||||
|
||||
"website/public/js/env.js",
|
||||
|
||||
"website/public/js/app.js",
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
// @TODO translations aren't loading
|
||||
|
||||
xdescribe('Auth Controller', function() {
|
||||
describe('Auth Controller', function() {
|
||||
|
||||
describe('AuthCtrl', function(){
|
||||
var scope, ctrl, user, $httpBackend, $window;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
describe('Filters Controller', function() {
|
||||
var scope, user;
|
||||
|
||||
beforeEach(module('habitrpg'));
|
||||
beforeEach(inject(function($rootScope, $controller, Shared) {
|
||||
user = specHelper.newUser();
|
||||
Shared.wrap(user);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
// @TODO the requests via $resource seem to be
|
||||
// doing a full page reload which breaks the specs
|
||||
// @TODO the requests via $resource seem to be
|
||||
// doing a full page reload which breaks the specs
|
||||
|
||||
xdescribe('groupServices', function() {
|
||||
var $httpBackend, groups;
|
||||
|
||||
@@ -66,13 +66,13 @@ describe('Inventory Controller', function() {
|
||||
expect(user.stats.gp).to.eql(1);
|
||||
});
|
||||
|
||||
xit('chooses a pet', function(){
|
||||
it('chooses a pet', function(){
|
||||
user.items.pets['Cactus-Base'] = 5;
|
||||
scope.choosePet('Cactus', 'Base');
|
||||
expect(user.items.currentPet).to.eql('Cactus-Base');
|
||||
});
|
||||
|
||||
xit('purchases an egg', inject(function(Content){
|
||||
it('purchases an egg', inject(function(Content){
|
||||
scope.purchase('eggs', Content.eggs['Wolf']);
|
||||
expect(user.balance).to.eql(3.25);
|
||||
expect(user.items.eggs).to.eql({Cactus: 1, Wolf: 1})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
// @TODO: Something here is calling a full page reload
|
||||
xdescribe('Root Controller', function() {
|
||||
var scope, user, ctrl;
|
||||
|
||||
@@ -11,8 +12,7 @@ xdescribe('Root Controller', function() {
|
||||
|
||||
ctrl = $controller('RootCtrl', {$scope: scope, User: {user: user}});
|
||||
}));
|
||||
|
||||
// @TODO: Fix translations not loading here
|
||||
|
||||
it('shows contributor level text', function(){
|
||||
expect(scope.contribText()).to.eql(undefined);
|
||||
expect(scope.contribText(null, {npc: 'NPC'})).to.eql('NPC');
|
||||
@@ -24,8 +24,9 @@ xdescribe('Root Controller', function() {
|
||||
expect(scope.contribText({level: 5, text: 'Blacksmith'})).to.eql('Champion Blacksmith');
|
||||
expect(scope.contribText({level: 6, text: 'Blacksmith'})).to.eql('Champion Blacksmith');
|
||||
expect(scope.contribText({level: 7, text: 'Blacksmith'})).to.eql('Legendary Blacksmith');
|
||||
expect(scope.contribText({level: 8, text: 'Blacksmith'})).to.eql('Heroic Blacksmith');
|
||||
expect(scope.contribText({level: 8, text: 'Blacksmith'}, {npc: 'NPC'})).to.eql('NPC');
|
||||
expect(scope.contribText({level: 8, text: 'Blacksmith'})).to.eql('Guardian Blacksmith');
|
||||
expect(scope.contribText({level: 9, text: 'Blacksmith'})).to.eql('Heroic Blacksmith');
|
||||
expect(scope.contribText({level: 9, text: 'Blacksmith'}, {npc: 'NPC'})).to.eql('NPC');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
2
test/spec/translations.js
Normal file
2
test/spec/translations.js
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user