client unit tests for autocomplete field()

This commit is contained in:
Carlos 2017-09-26 18:21:11 +02:00
parent f647e9e2d1
commit 0a17a59f2d
1 changed files with 20 additions and 0 deletions

View File

@ -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');
});
});
});
}); });