habitica/test/spec/filtersCtrlSpec.js
Kevin Gisi 09b6401794 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.
2015-03-24 21:39:03 -04:00

27 lines
787 B
JavaScript

'use strict';
describe('Filters Controller', function() {
var scope, user;
beforeEach(inject(function($rootScope, $controller, Shared) {
user = specHelper.newUser();
Shared.wrap(user);
scope = $rootScope.$new();
$controller('FiltersCtrl', {$scope: scope, User: {user: user}});
}));
it('creates a tag', function(){
scope.createTag('tagName');
expect(user.tags).to.have.length(1);
expect(user.tags[0].name).to.eql('tagName');
expect(user.tags[0]).to.have.property('id');
});
it('toggles tag filtering', inject(function(Shared){
var tag = {id: Shared.uuid(), name: 'myTag'};
scope.toggleFilter(tag);
expect(user.filters[tag.id]).to.eql(true);
scope.toggleFilter(tag);
expect(user.filters[tag.id]).to.eql(false);
}))
});