Autocomplete client side unit tests finished
This commit is contained in:
parent
7d1bc60112
commit
57b03790a3
|
@ -195,5 +195,24 @@ describe('Component vnAutocomplete', () => {
|
||||||
|
|
||||||
expect(controller.items).toEqual([{id: 3, name: 'The Joker', checked: false}, {id: 4, name: 'Joker', checked: false}]);
|
expect(controller.items).toEqual([{id: 3, name: 'The Joker', checked: false}, {id: 4, name: 'Joker', checked: false}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it(`should call getItems function if there's no search value`, () => {
|
||||||
|
let controller = $componentController('vnAutocomplete', {$scope, $element, $httpBackend, $timeout}, {url: 'test.com'});
|
||||||
|
spyOn(controller, 'getItems');
|
||||||
|
controller.findItems();
|
||||||
|
|
||||||
|
expect(controller.getItems).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('getItem()', () => {
|
||||||
|
it(`should perfom a query to fill the items without filter`, () => {
|
||||||
|
let controller = $componentController('vnAutocomplete', {$scope, $element, $httpBackend, $timeout}, {url: 'test.com'});
|
||||||
|
$httpBackend.whenGET(`test.com?filter={"skip":0,"limit":10,"order":"name ASC"}`).respond([{id: 1, name: 'Batman'}, {id: 2, name: 'Bruce Wayne'}]);
|
||||||
|
$httpBackend.expectGET(`test.com?filter={"skip":0,"limit":10,"order":"name ASC"}`);
|
||||||
|
controller.getItems();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.items).toEqual([{id: 1, name: 'Batman'}, {id: 2, name: 'Bruce Wayne'}]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue