From 913afc8f398a09c27ae7cd9148c43d848ed9eed9 Mon Sep 17 00:00:00 2001 From: Joy Clark Date: Sat, 25 Apr 2015 23:22:39 +0200 Subject: [PATCH] #5085 restructured unit tests for AutocompleteCtrl --- test/spec/groupCtrlSpec.js | 47 +++++++++++++++----------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/test/spec/groupCtrlSpec.js b/test/spec/groupCtrlSpec.js index 24f6b891f8..222b7b611b 100644 --- a/test/spec/groupCtrlSpec.js +++ b/test/spec/groupCtrlSpec.js @@ -67,40 +67,29 @@ describe('Groups Controller', function() { }); describe("Autocomplete controller", function() { - beforeEach(module('habitrpg')); + var $scope, controller; - var $controller; - - beforeEach(inject(function(_$controller_) { - $controller = _$controller_; + beforeEach(inject(function($controller) { + $scope = {query: undefined, $watch: function(task,fn) {}}; // mock watch & t function + controller = $controller('AutocompleteCtrl', {$scope: $scope}); })); - 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() { + 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 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 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 - }) - - }); + it('filtering with nonprefix element will return false', function() { + $scope.query = {text: "noprefix"} + expect($scope.filterUser({user: "prefix"})).to.not.be.ok + }) }); \ No newline at end of file