Skip to content

Commit

Permalink
fix: ensure option bound value type is preserved closes #3440
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Sep 26, 2021
1 parent d8438e0 commit 9283f61
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/vee-validate/tests/Field.spec.ts
Expand Up @@ -1125,4 +1125,38 @@ describe('<Field />', () => {
expect(error.textContent).toBe('');
expect(input.value).toBe('');
});

// #3440
test('should preserve select input options value type', async () => {
const value = ref();

const wrapper = mountWithHoc({
setup() {
return {
value,
};
},
template: `
<Field as="select" v-model="value" name="hello">
<option id="true" :value="true">Yes</option>
<option id="false" :value="false">No</option>
</Field>
`,
});

await flushPromises();
const select = document.querySelector('select') as HTMLSelectElement;
const optTrue = document.querySelector('#true') as HTMLOptionElement;
const optFalse = document.querySelector('#false') as HTMLOptionElement;

optTrue.selected = true;
dispatchEvent(select, 'change');
await flushPromises();
expect(value.value).toBe(true);

optFalse.selected = true;
dispatchEvent(select, 'change');
await flushPromises();
expect(value.value).toBe(false);
});
});

0 comments on commit 9283f61

Please sign in to comment.