describe("DocsNavigationCtrl", function() { beforeEach(module('docsApp')); var ctrl, $scope; beforeEach(function() { module(function($provide) { $provide.value('docsPages', []); $provide.factory('docsSearch', function() { return function(q) { return ['one','two','three']; }; }); }); inject(function($controller, $rootScope, $location, docsSearch) { $scope = $rootScope.$new(); ctrl = $controller('DocsNavigationCtrl', { $scope : $scope, $location : $location, docsSearch : docsSearch }); }); }); it("should search and return data from docsSearch", function() { $scope.search('1234') expect($scope.results.join(',')).toBe('one,two,three'); expect($scope.hasResults).toBe(true); }); it("should avoid searching if the search term is too short", function() { $scope.search('1') expect($scope.results.length).toBe(0); expect($scope.hasResults).toBe(false); }); it("should set the columns classname based on the total grouped results", function() { $scope.search('1234'); expect($scope.colClassName).toBe('cols-3'); $scope.search('1'); expect($scope.colClassName).toBe(null); }); it("should hide and clear the results when called", function() { $scope.hasResults = true; $scope.results = ['one']; $scope.colClassName = '...'; $scope.hideResults(); expect($scope.hasResults).toBe(false); expect($scope.results.length).toBe(0); expect($scope.colClassName).toBe(null); }); it("should hide, clear and change the path of the page when submitted", inject(function($location) { $scope.hasResults = true; $scope.results = { api : [ {url : '/home'} ], tutorial : [ {url : '/tutorial'} ] }; $scope.submit(); expect($location.path()).toBe('/home'); expect($scope.results.length).toBe(0); expect($scope.hasResults).toBe(false); })); }); nent-spec/NavigationCtrlSpec.js?h=v1.2.9&id=d69cd7d9ca124baea2c116b7db28468f60ad7fea'>diffstats
path: root/docs/component-spec/NavigationCtrlSpec.js
blob: d7a9da452aea724ff3ae32d3adf01b328dadc635 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72