diff --git a/client/core/src/autocomplete/autocomplete.spec.js b/client/core/src/autocomplete/autocomplete.spec.js index 9ebd6f052..99be2f97b 100644 --- a/client/core/src/autocomplete/autocomplete.spec.js +++ b/client/core/src/autocomplete/autocomplete.spec.js @@ -57,4 +57,24 @@ describe('Component vnAutocomplete', () => { }); }); }); + + describe('field() setter', () => { + describe('when value is an object with valueField property', () => { + it(`should set _field and _multifield values and remove it from _multifield if called again`, () => { + let controller = $componentController('vnAutocomplete', {$scope, $element, $httpBackend, $timeout}); + controller.valueField = 'name'; + controller.field = {name: 'Bruce Wayne'}; + + expect(controller._field).toEqual('Bruce Wayne'); + expect(controller._multiField[0]).toEqual('Bruce Wayne'); + + controller.field = {name: 'Bruce Wayne'}; + + expect(controller._multiField).toEqual([]); + + // value is still stored in _field after second call... is this correct? or should be deleted as per _multifield? ask Dani! + expect(controller._field).toEqual('Bruce Wayne'); + }); + }); + }); });