From 106d7d83647b4c4720ed25832f11cb379b01e488 Mon Sep 17 00:00:00 2001 From: Carlos Date: Tue, 3 Oct 2017 09:18:12 +0200 Subject: [PATCH] autocomplete client side unit test for findItems() with multiple --- client/core/src/autocomplete/autocomplete.spec.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/client/core/src/autocomplete/autocomplete.spec.js b/client/core/src/autocomplete/autocomplete.spec.js index 8999e25b0..0f31b5d96 100644 --- a/client/core/src/autocomplete/autocomplete.spec.js +++ b/client/core/src/autocomplete/autocomplete.spec.js @@ -171,7 +171,7 @@ describe('Component vnAutocomplete', () => { expect(controller.items.length).toEqual(2); }); - it(`should perform a query with the search value if the finding flag is false`, () => { + it(`should perform a search and store the result in controller items`, () => { let controller = $componentController('vnAutocomplete', {$scope, $element, $httpBackend, $timeout}, {url: 'test.com'}); let search = 'The Joker'; let json = JSON.stringify({where: {name: {regexp: search}}}); @@ -183,18 +183,17 @@ describe('Component vnAutocomplete', () => { expect(controller.items[0]).toEqual({id: 3, name: 'The Joker'}); }); - it(`should perform a query with the search value if the finding flag is false`, () => { + it(`should perform a search with multiple true and store the result in controller items with the checked property defined`, () => { let controller = $componentController('vnAutocomplete', {$scope, $element, $httpBackend, $timeout}, {url: 'test.com'}); - let search = 'The Joker'; + let search = 'Joker'; + controller.multiple = true; let json = JSON.stringify({where: {name: {regexp: search}}}); - $httpBackend.whenGET(`test.com?filter=${json}`).respond([{id: 3, name: 'The Joker'}]); + $httpBackend.whenGET(`test.com?filter=${json}`).respond([{id: 3, name: 'The Joker'}, {id: 4, name: 'Joker'}]); $httpBackend.expectGET(`test.com?filter=${json}`); controller.findItems(search); $httpBackend.flush(); - expect(controller.items[0]).toEqual({id: 3, name: 'The Joker'}); + expect(controller.items).toEqual([{id: 3, name: 'The Joker', checked: false}, {id: 4, name: 'Joker', checked: false}]); }); - - // siguiente test el de Multiple! }); });