#5085 added some unit tests.

This commit is contained in:
Joy Clark 2015-04-25 23:08:28 +02:00
parent 0a2890d1eb
commit 3458815f28

View file

@ -65,3 +65,42 @@ describe('Groups Controller', function() {
expect(myGuilds).to.be.called
});
});
describe("Autocomplete controller", function() {
beforeEach(module('habitrpg'));
var $controller;
beforeEach(inject(function(_$controller_) {
$controller = _$controller_;
}));
describe("AutocompleteCtrl", function() {
var $scope, controller;
beforeEach(function() {
$scope = {query: undefined, $watch: function(task,fn) {}}; // mock watch function
controller = $controller('AutocompleteCtrl', {$scope: $scope});
})
it('filtering with undefined query (not loaded yet) defaults to true', function() {
expect($scope.filterUser({user: "boo"})).to.be.ok
})
it('filtering with null query (no typing yet) defaults to true', function() {
$scope.query = null
expect($scope.filterUser({user: "boo"})).to.be.ok
})
it('filtering with prefix element will return true', function() {
$scope.query = {text: "pre"}
expect($scope.filterUser({user: "prefix"})).to.be.ok
})
it('filtering with nonprefix element will return false', function() {
$scope.query = {text: "noprefix"}
expect($scope.filterUser({user: "prefix"})).to.not.be.ok
})
});
});