This repository has been archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Elliott Grieco
committed
Oct 19, 2018
1 parent
ec02f1e
commit c4f9fb9
Showing
5 changed files
with
154 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
const libraryh3lpWidgetConfig = __fixtures__['libraryh3lpWidgetConfig']; | ||
|
||
describe('libraryh3lpWidgetResultsListController', () => { | ||
|
||
beforeEach(module('libraryh3lpWidget', ($provide) => { | ||
$provide.constant('libraryh3lpWidgetConfig', libraryh3lpWidgetConfig); | ||
})); | ||
|
||
let $scope, $componentController; | ||
let controller, bindings; | ||
let libraryh3lpWidgetResultsList; | ||
const parentCtrl = {}; | ||
beforeEach(inject(function (_$rootScope_, _$componentController_, _libraryh3lpWidgetResultsList_) { | ||
libraryh3lpWidgetResultsList = _libraryh3lpWidgetResultsList_; | ||
const $rootScope = _$rootScope_; | ||
$componentController = _$componentController_; | ||
$scope = $rootScope.$new(); | ||
|
||
// content of results irrelevant because it's just checking for length' | ||
angular.merge(parentCtrl, { | ||
searchService: { | ||
facetService: { | ||
results: [null, null, null] | ||
} | ||
} | ||
}); | ||
bindings = { parentCtrl }; | ||
|
||
controller = $componentController('prmExploreMainAfter', { $scope }, bindings); | ||
})); | ||
|
||
describe('$onInit', () => { | ||
beforeEach(() => { | ||
spyOn(libraryh3lpWidgetResultsList, 'getLength'); | ||
spyOn(libraryh3lpWidgetResultsList, 'updateLength'); | ||
controller.$onInit(); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller.$onInit).toBeDefined(); | ||
}); | ||
|
||
it(`should call libraryh3lpWidgetResultsList.updateLength with length of results`, () => { | ||
expect(libraryh3lpWidgetResultsList.updateLength).toHaveBeenCalledWith(3); | ||
}); | ||
}); | ||
|
||
describe(`$doCheck`, () => { | ||
beforeEach(() => { | ||
spyOn(libraryh3lpWidgetResultsList, 'getLength'); | ||
spyOn(libraryh3lpWidgetResultsList, 'updateLength'); | ||
controller.$onInit(); | ||
|
||
libraryh3lpWidgetResultsList.updateLength.calls.reset(); | ||
controller.$doCheck(); | ||
}); | ||
|
||
describe(`if length has not changed`, () => { | ||
it(`shouldn't updateLength`, () => { | ||
expect(libraryh3lpWidgetResultsList.updateLength).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe(`if length has changed`, () => { | ||
it(`should updateLength with new length`, () => { | ||
parentCtrl.searchService.facetService.results.push(null); | ||
controller.$doCheck(); | ||
expect(libraryh3lpWidgetResultsList.updateLength).toHaveBeenCalledWith(4); | ||
|
||
parentCtrl.searchService.facetService.results = []; | ||
controller.$doCheck(); | ||
expect(libraryh3lpWidgetResultsList.updateLength).toHaveBeenCalledWith(0); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
describe('libraryh3lpWidgetResultsList factory', () => { | ||
let libraryh3lpWidgetResultsList; | ||
beforeEach(() => { | ||
module('libraryh3lpWidget'); | ||
inject(function (_libraryh3lpWidgetResultsList_) { | ||
libraryh3lpWidgetResultsList = _libraryh3lpWidgetResultsList_; | ||
}); | ||
}); | ||
|
||
describe('getLength', () => { | ||
it('has the function', () => { | ||
expect(libraryh3lpWidgetResultsList.getLength).toBeDefined(); | ||
}); | ||
|
||
it('initialized to 0', () => { | ||
expect(libraryh3lpWidgetResultsList.getLength()).toEqual(0); | ||
}); | ||
}); | ||
|
||
describe('updateLength', () => { | ||
it('has the function', () => { | ||
expect(libraryh3lpWidgetResultsList.updateLength).toBeDefined(); | ||
}); | ||
|
||
it('updates the length', () => { | ||
libraryh3lpWidgetResultsList.updateLength(100); | ||
|
||
expect(libraryh3lpWidgetResultsList.getLength()).toEqual(100); | ||
}); | ||
}); | ||
}); |