df7d36923c
Add search input box next to the tags. When user changes the value of the input box then it's propagated to the user service as filterQuery string. filterQuery string is then used in the tasks template to filter tasks by text.
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
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._newTag = {name:'tagName'}
|
|
scope.createTag();
|
|
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);
|
|
}));
|
|
|
|
it('updates user\'s filter query when filterQuery is changed', function () {
|
|
scope.$apply();
|
|
|
|
scope.filterQuery = 'foo';
|
|
scope.$apply();
|
|
|
|
expect(user.filterQuery).to.eql('foo');
|
|
});
|
|
});
|