2
0
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:
Owen Conti
2019-03-23 12:25:31 -06:00
committed by Jeff Sagal
parent f95b118edb
commit f9725919a4
16 changed files with 250 additions and 1950 deletions
+19 -11
View File
@@ -2,10 +2,12 @@ import { selectWithProps } from "../helpers";
describe("Removing values", () => {
it("can remove the given tag when its close icon is clicked", () => {
const Select = selectWithProps({ multiple: true, value: ["foo"] });
const Select = selectWithProps({ multiple: true });
Select.vm.$data._value = 'one';
Select.find(".vs__deselect").trigger("click");
expect(Select.vm.mutableValue).toEqual([]);
expect(Select.emitted().input).toEqual([[[]]]);
expect(Select.vm.selectedValue).toEqual([]);
});
it("should not remove tag when close icon is clicked and component is disabled", () => {
@@ -17,28 +19,32 @@ describe("Removing values", () => {
});
Select.find(".vs__deselect").trigger("click");
expect(Select.vm.mutableValue).toEqual(["one"]);
expect(Select.vm.selectedValue).toEqual(["one"]);
});
it("should remove the last item in the value array on delete keypress when multiple is true", () => {
const Select = selectWithProps({
multiple: true,
value: ["one", "two"],
options: ["one", "two", "three"]
});
Select.vm.maybeDeleteValue();
expect(Select.vm.mutableValue).toEqual(["one"]);
Select.vm.$data._value = ["one", "two"];
Select.find('.vs__search').trigger('keydown.backspace')
expect(Select.emitted().input).toEqual([[['one']]]);
expect(Select.vm.selectedValue).toEqual(["one"]);
});
it("should set value to null on delete keypress when multiple is false", () => {
const Select = selectWithProps({
value: "one",
options: ["one", "two", "three"]
});
Select.vm.$data._value = 'one';
Select.vm.maybeDeleteValue();
expect(Select.vm.mutableValue).toEqual(null);
expect(Select.vm.selectedValue).toEqual([]);
});
describe("Clear button", () => {
@@ -64,12 +70,14 @@ describe("Removing values", () => {
it("should remove selected value when clicked", () => {
const Select = selectWithProps({
options: ["foo", "bar"],
value: "foo"
});
Select.vm.$data._value = 'foo';
expect(Select.vm.mutableValue).toEqual("foo");
expect(Select.vm.selectedValue).toEqual(["foo"]);
Select.find("button.vs__clear").trigger("click");
expect(Select.vm.mutableValue).toEqual(null);
expect(Select.emitted().input).toEqual([[null]]);
expect(Select.vm.selectedValue).toEqual([]);
});
it("should be disabled when component is disabled", () => {