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

@@ -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

View File

@@ -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",

View File

@@ -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;

View File

@@ -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);

View File

@@ -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})

View File

@@ -1,5 +1,6 @@
'use strict';
// @TODO: Something here is calling a full page reload
xdescribe('Root Controller', function() {
var scope, user, ctrl;
@@ -12,7 +13,6 @@ 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');
});
});

File diff suppressed because one or more lines are too long