From ced1609e514644e76fafd70a8d4a0deb0dafd493 Mon Sep 17 00:00:00 2001 From: slhale Date: Fri, 14 Aug 2015 13:52:57 -0700 Subject: [PATCH] [Search] Update tests Updated SearchController test for the addition of the controller's dependency on types[]. --- .../test/controllers/SearchControllerSpec.js | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/platform/search/test/controllers/SearchControllerSpec.js b/platform/search/test/controllers/SearchControllerSpec.js index 56aa1e4618..dcaf43cd88 100644 --- a/platform/search/test/controllers/SearchControllerSpec.js +++ b/platform/search/test/controllers/SearchControllerSpec.js @@ -33,13 +33,16 @@ define( var mockScope, mockSearchService, mockPromise, + mockSearchResult, + mockDomainObject, + mockTypes, controller; function bigArray(size) { var array = [], i; for (i = 0; i < size; i += 1) { - array.push(i); + array.push(mockSearchResult); } return array; } @@ -48,10 +51,12 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj( "$scope", - [ "" ] + [ "$watch" ] ); mockScope.ngModel = {}; mockScope.ngModel.input = "test input"; + mockScope.ngModel.checked = {}; + mockScope.ngModel.checked['mock.type'] = true; mockSearchService = jasmine.createSpyObj( "searchService", @@ -63,7 +68,20 @@ define( ); mockSearchService.query.andReturn(mockPromise); - controller = new SearchController(mockScope, mockSearchService); + mockTypes = [{key: 'mock.type', name: 'Mock Type', glyph: '?'}]; + + mockSearchResult = jasmine.createSpyObj( + "searchResult", + [ "" ] + ); + mockDomainObject = jasmine.createSpyObj( + "domainObject", + [ "getModel" ] + ); + mockSearchResult.object = mockDomainObject; + mockDomainObject.getModel.andReturn({name: 'Mock Object', type: 'mock.type'}); + + controller = new SearchController(mockScope, mockSearchService, mockTypes); controller.search(); }); @@ -100,7 +118,7 @@ define( it("can load more results", function () { var oldSize; - expect(mockPromise.then).toHaveBeenCalledWith(jasmine.any(Function)); + expect(mockPromise.then).toHaveBeenCalled(); mockPromise.then.mostRecentCall.args[0]({hits: bigArray(100), total: 1000}); oldSize = mockScope.results.length;