mirror of
https://github.com/tenrok/vue-select.git
synced 2026-05-17 02:29:37 +03:00
fix(reduce): reduce + taggable bug (#1091)
Resolves #1089 Resolves #993
This commit is contained in:
@@ -226,4 +226,33 @@ describe("When reduce prop is defined", () => {
|
||||
|
||||
expect(Select.vm.selectedValue).toEqual([optionToChangeTo]);
|
||||
});
|
||||
|
||||
describe('Reducing Tags', () => {
|
||||
it('tracks values that have been created by the user', async () => {
|
||||
const Parent = mount({
|
||||
data: () => ({selected: null, options: []}),
|
||||
template: `
|
||||
<v-select
|
||||
v-model="selected"
|
||||
:options="options"
|
||||
taggable
|
||||
:reduce="name => name.value"
|
||||
:create-option="label => ({ label, value: -1 })"
|
||||
/>
|
||||
`,
|
||||
components: {'v-select': VueSelect},
|
||||
});
|
||||
const Select = Parent.vm.$children[0];
|
||||
|
||||
// When
|
||||
Select.search = 'hello';
|
||||
Select.typeAheadSelect();
|
||||
await Select.$nextTick();
|
||||
|
||||
// Then
|
||||
expect(Select.selectedValue).toEqual([{label: 'hello', value: -1}]);
|
||||
expect(Select.$refs.selectedOptions.textContent.trim()).toEqual('hello');
|
||||
expect(Parent.vm.selected).toEqual(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user