mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-19 09:50:33 +03:00
V3 - Remove mutable class properties plus other misc changes (#781)
* Remove the mutableValue prop in the Select component. * Add back mutable value when Vue Select has to manage its own value. * Remove mutableOptions, valueAsAarray. Update webpack minifer to use Terser. * Fix tabbing * Fix bug with showClearButton * Fix tests. * Call clearSelection when possible * Update dev sandbox to have all three options for setting value. * Update dev sandbox to display current value * Remove unused karma test setup. * Revert onInput name change. * Use coveralls * Change this.internalValue to this.$data._value. * Remove onInput prop and replace with internal method, updateValue. * Update tests. * Rename optionObjectComparator to optionComparator.
This commit is contained in:
@@ -15,7 +15,7 @@ describe("VS - Selecting Values", () => {
|
||||
const Select = shallowMount(VueSelect, {
|
||||
propsData: defaultProps
|
||||
});
|
||||
expect(Select.mutableValue).toEqual(Select.value);
|
||||
expect(Select.selectedValue).toEqual(Select.value);
|
||||
});
|
||||
|
||||
it("can accept an array of objects and pre-selected value (single)", () => {
|
||||
@@ -28,7 +28,7 @@ describe("VS - Selecting Values", () => {
|
||||
]
|
||||
}
|
||||
});
|
||||
expect(Select.mutableValue).toEqual(Select.value);
|
||||
expect(Select.selectedValue).toEqual(Select.value);
|
||||
});
|
||||
|
||||
it("can accept an array of objects and pre-selected values (multiple)", () => {
|
||||
@@ -46,7 +46,7 @@ describe("VS - Selecting Values", () => {
|
||||
multiple: true
|
||||
});
|
||||
|
||||
expect(Select.mutableValue).toEqual(Select.value);
|
||||
expect(Select.selectedValue).toEqual(Select.value);
|
||||
});
|
||||
|
||||
it("can select an option on tab", () => {
|
||||
@@ -67,10 +67,6 @@ describe("VS - Selecting Values", () => {
|
||||
const Select = shallowMount(VueSelect, {
|
||||
propsData: {
|
||||
multiple: true,
|
||||
value: [
|
||||
{ label: "This is Foo", value: "foo" },
|
||||
{ label: "This is Bar", value: "bar" }
|
||||
],
|
||||
options: [
|
||||
{ label: "This is Foo", value: "foo" },
|
||||
{ label: "This is Bar", value: "bar" }
|
||||
@@ -78,36 +74,41 @@ describe("VS - Selecting Values", () => {
|
||||
}
|
||||
});
|
||||
|
||||
Select.vm.$data._value = [
|
||||
{ label: "This is Foo", value: "foo" },
|
||||
{ label: "This is Bar", value: "bar" }
|
||||
];
|
||||
|
||||
Select.vm.deselect({ label: "This is Foo", value: "foo" });
|
||||
expect(Select.vm.mutableValue.length).toEqual(1);
|
||||
expect(Select.vm.selectedValue).toEqual([{ label: "This is Bar", value: "bar" }]);
|
||||
});
|
||||
|
||||
it("can deselect a pre-selected string", () => {
|
||||
const Select = shallowMount(VueSelect, {
|
||||
propsData: {
|
||||
multiple: true,
|
||||
value: ["foo", "bar"],
|
||||
options: ["foo", "bar"]
|
||||
}
|
||||
});
|
||||
|
||||
Select.vm.$data._value = "foo";
|
||||
|
||||
Select.vm.deselect("foo");
|
||||
expect(Select.vm.mutableValue.length).toEqual(1);
|
||||
expect(Select.vm.selectedValue).toEqual([]);
|
||||
});
|
||||
|
||||
it("can deselect an option when multiple is false", () => {
|
||||
const Select = shallowMount(VueSelect, {
|
||||
propsData: {
|
||||
value: "foo"
|
||||
}
|
||||
});
|
||||
const Select = shallowMount(VueSelect);
|
||||
|
||||
Select.vm.$data._value = "foo";
|
||||
|
||||
Select.vm.deselect("foo");
|
||||
expect(Select.vm.mutableValue).toEqual(null);
|
||||
expect(Select.vm.selectedValue).toEqual([]);
|
||||
});
|
||||
|
||||
it("can determine if the value prop is empty", () => {
|
||||
const Select = shallowMount(VueSelect, {
|
||||
propsData: {
|
||||
value: [],
|
||||
options: ["one", "two", "three"]
|
||||
}
|
||||
});
|
||||
@@ -134,19 +135,16 @@ describe("VS - Selecting Values", () => {
|
||||
it("should reset the selected values when the multiple property changes", () => {
|
||||
const Select = shallowMount(VueSelect, {
|
||||
propsData: {
|
||||
value: ["one"],
|
||||
multiple: true,
|
||||
options: ["one", "two", "three"]
|
||||
}
|
||||
});
|
||||
|
||||
expect(Select.vm.mutableValue).toEqual(["one"]);
|
||||
|
||||
Select.setProps({ multiple: false });
|
||||
expect(Select.vm.mutableValue).toEqual(null);
|
||||
expect(Select.vm.selectedValue).toEqual([]);
|
||||
|
||||
Select.setProps({ multiple: true });
|
||||
expect(Select.vm.mutableValue).toEqual([]);
|
||||
expect(Select.vm.selectedValue).toEqual([]);
|
||||
});
|
||||
|
||||
it("can retain values present in a new array of options", () => {
|
||||
@@ -158,7 +156,7 @@ describe("VS - Selecting Values", () => {
|
||||
});
|
||||
|
||||
Select.setProps({ options: ["one", "five", "six"] });
|
||||
expect(Select.vm.mutableValue).toEqual(["one"]);
|
||||
expect(Select.vm.selectedValue).toEqual(["one"]);
|
||||
});
|
||||
|
||||
it("can determine if an object is already selected", () => {
|
||||
@@ -181,7 +179,7 @@ describe("VS - Selecting Values", () => {
|
||||
const Select = Parent.vm.$children[0];
|
||||
|
||||
expect(Select.value).toEqual("foo");
|
||||
expect(Select.mutableValue).toEqual("foo");
|
||||
expect(Select.selectedValue).toEqual(["foo"]);
|
||||
|
||||
Select.select("bar");
|
||||
expect(Parent.vm.value).toEqual("bar");
|
||||
|
||||
Reference in New Issue
Block a user