mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-03 14:23:12 +02:00
fix: remove extra 'undefined' argument when calling _addItem from _addChoice
+ Added integration-like test
This commit is contained in:
parent
8ed2139335
commit
af9feb3e2c
|
@ -2205,7 +2205,6 @@ class Choices {
|
|||
choiceLabel,
|
||||
choiceId,
|
||||
undefined,
|
||||
undefined,
|
||||
customProperties
|
||||
);
|
||||
}
|
||||
|
@ -2254,7 +2253,8 @@ class Choices {
|
|||
label,
|
||||
option.selected,
|
||||
isOptDisabled,
|
||||
groupId
|
||||
groupId,
|
||||
option.customProperties
|
||||
);
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -1038,5 +1038,23 @@ describe('Choices', () => {
|
|||
expect(selectedItems.length).toBe(1);
|
||||
expect(selectedItems[0].customProperties).toBe(expectedCustomProperties);
|
||||
});
|
||||
|
||||
it('should allow the user to supply custom properties when directly creating a selected item', function() {
|
||||
const expectedCustomProperties = {
|
||||
isBestOptionEver: true
|
||||
};
|
||||
|
||||
this.choices = new Choices(this.input);
|
||||
|
||||
this.choices.setValue([{
|
||||
value: 'bar',
|
||||
label: 'foo',
|
||||
customProperties: expectedCustomProperties
|
||||
}]);
|
||||
const selectedItems = this.choices.getValue();
|
||||
|
||||
expect(selectedItems.length).toBe(1);
|
||||
expect(selectedItems[0].customProperties).toBe(expectedCustomProperties);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue