mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
#5085 restructured unit tests for AutocompleteCtrl
This commit is contained in:
@@ -67,40 +67,29 @@ describe('Groups Controller', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("Autocomplete controller", function() {
|
describe("Autocomplete controller", function() {
|
||||||
beforeEach(module('habitrpg'));
|
var $scope, controller;
|
||||||
|
|
||||||
var $controller;
|
beforeEach(inject(function($controller) {
|
||||||
|
$scope = {query: undefined, $watch: function(task,fn) {}}; // mock watch & t function
|
||||||
beforeEach(inject(function(_$controller_) {
|
controller = $controller('AutocompleteCtrl', {$scope: $scope});
|
||||||
$controller = _$controller_;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("AutocompleteCtrl", function() {
|
it('filtering with undefined query (not loaded yet) defaults to true', 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
|
expect($scope.filterUser({user: "boo"})).to.be.ok
|
||||||
})
|
})
|
||||||
|
|
||||||
it('filtering with null query (no typing yet) defaults to true', function() {
|
it('filtering with null query (no typing yet) defaults to true', function() {
|
||||||
$scope.query = null
|
$scope.query = null
|
||||||
expect($scope.filterUser({user: "boo"})).to.be.ok
|
expect($scope.filterUser({user: "boo"})).to.be.ok
|
||||||
})
|
})
|
||||||
|
|
||||||
it('filtering with prefix element will return true', function() {
|
it('filtering with prefix element will return true', function() {
|
||||||
$scope.query = {text: "pre"}
|
$scope.query = {text: "pre"}
|
||||||
expect($scope.filterUser({user: "prefix"})).to.be.ok
|
expect($scope.filterUser({user: "prefix"})).to.be.ok
|
||||||
})
|
})
|
||||||
|
|
||||||
it('filtering with nonprefix element will return false', function() {
|
it('filtering with nonprefix element will return false', function() {
|
||||||
$scope.query = {text: "noprefix"}
|
$scope.query = {text: "noprefix"}
|
||||||
expect($scope.filterUser({user: "prefix"})).to.not.be.ok
|
expect($scope.filterUser({user: "prefix"})).to.not.be.ok
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user