2
0
mirror of https://github.com/tenrok/vue-select.git synced 2026-06-16 09:10:33 +03:00

fix: Compare Options with getOptionKey instead of label + reduce (#1012)

This commit is contained in:
Jeff Sagal
2020-03-08 17:58:06 -07:00
committed by GitHub
parent ca2c36c25b
commit bc9553a82e
9 changed files with 162 additions and 72 deletions
+13 -2
View File
@@ -1,5 +1,6 @@
import { mount, shallowMount } from "@vue/test-utils";
import VueSelect from "../../src/components/Select.vue";
import { mountDefault } from '../helpers';
describe("VS - Selecting Values", () => {
let defaultProps;
@@ -192,10 +193,20 @@ describe("VS - Selecting Values", () => {
value: [{ label: "foo", value: "bar" }]
}
});
expect(Select.vm.isOptionSelected("foo")).toEqual(true);
expect(Select.vm.isOptionSelected({ label: "foo", value: "bar" })).toEqual(true);
});
describe("change Event", () => {
it('can select two options with the same label', () => {
const options = [{label: 'one', id: 1}, {label: 'one', id: 2}];
const Select = mountDefault({options, multiple: true});
Select.vm.select({label: 'one', id: 1});
Select.vm.select({label: 'one', id: 2});
expect(Select.vm.selectedValue).toEqual(options);
});
describe("input Event", () => {
it("will trigger the input event when the selection changes", () => {
const Select = shallowMount(VueSelect);
Select.vm.select("bar");