2014-01-05 01:40:57 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
describe('Filters Controller', function() {
|
|
|
|
|
var scope, user;
|
|
|
|
|
|
|
|
|
|
beforeEach(module('habitrpg'));
|
2014-01-12 23:05:15 +00:00
|
|
|
beforeEach(inject(function($rootScope, $controller, Shared) {
|
2014-01-05 01:40:57 +00:00
|
|
|
user = {filters: {}};
|
2014-01-12 23:05:15 +00:00
|
|
|
Shared.wrap(user);
|
2014-01-05 01:40:57 +00:00
|
|
|
scope = $rootScope.$new();
|
|
|
|
|
$controller('FiltersCtrl', {$scope: scope, User: {user: user}});
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
it('creates a tag', function(){
|
|
|
|
|
scope.createTag('tagName');
|
2014-01-14 02:20:33 +00:00
|
|
|
expect(user.tags).to.have.length(1);
|
|
|
|
|
expect(user.tags[0].name).to.eql('tagName');
|
|
|
|
|
expect(user.tags[0]).to.have.property('id');
|
2014-01-05 01:40:57 +00:00
|
|
|
});
|
|
|
|
|
|
2014-01-12 23:05:15 +00:00
|
|
|
it('toggles tag filtering', inject(function(Shared){
|
|
|
|
|
var tag = {id: Shared.uuid(), name: 'myTag'};
|
2014-01-05 01:40:57 +00:00
|
|
|
scope.toggleFilter(tag);
|
|
|
|
|
expect(user.filters[tag.id]).to.eql(true);
|
|
|
|
|
scope.toggleFilter(tag);
|
|
|
|
|
expect(user.filters[tag.id]).to.eql(false);
|
2014-01-12 23:05:15 +00:00
|
|
|
}))
|
|
|
|
|
});
|