mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
refactor: apply eslint fixes (#1469)
This commit is contained in:
@@ -1,107 +1,107 @@
|
||||
import { mountDefault, selectWithProps } from '../helpers';
|
||||
import { mountDefault, selectWithProps } from '../helpers'
|
||||
|
||||
describe("Removing values", () => {
|
||||
it("can remove the given tag when its close icon is clicked", async () => {
|
||||
const Select = selectWithProps({ multiple: true });
|
||||
Select.vm.$data._value = 'one';
|
||||
await Select.vm.$nextTick();
|
||||
describe('Removing values', () => {
|
||||
it('can remove the given tag when its close icon is clicked', async () => {
|
||||
const Select = selectWithProps({ multiple: true })
|
||||
Select.vm.$data._value = 'one'
|
||||
await Select.vm.$nextTick()
|
||||
|
||||
Select.find(".vs__deselect").trigger("click");
|
||||
expect(Select.emitted().input).toEqual([[[]]]);
|
||||
expect(Select.vm.selectedValue).toEqual([]);
|
||||
});
|
||||
Select.find('.vs__deselect').trigger('click')
|
||||
expect(Select.emitted().input).toEqual([[[]]])
|
||||
expect(Select.vm.selectedValue).toEqual([])
|
||||
})
|
||||
|
||||
it("should not remove tag when close icon is clicked and component is disabled", () => {
|
||||
it('should not remove tag when close icon is clicked and component is disabled', () => {
|
||||
const Select = selectWithProps({
|
||||
value: ["one"],
|
||||
options: ["one", "two", "three"],
|
||||
value: ['one'],
|
||||
options: ['one', 'two', 'three'],
|
||||
multiple: true,
|
||||
disabled: true
|
||||
});
|
||||
disabled: true,
|
||||
})
|
||||
|
||||
Select.find(".vs__deselect").trigger("click");
|
||||
expect(Select.vm.selectedValue).toEqual(["one"]);
|
||||
});
|
||||
Select.find('.vs__deselect').trigger('click')
|
||||
expect(Select.vm.selectedValue).toEqual(['one'])
|
||||
})
|
||||
|
||||
it("should remove the last item in the value array on delete keypress when multiple is true", () => {
|
||||
it('should remove the last item in the value array on delete keypress when multiple is true', () => {
|
||||
const Select = selectWithProps({
|
||||
multiple: true,
|
||||
options: ["one", "two", "three"]
|
||||
});
|
||||
options: ['one', 'two', 'three'],
|
||||
})
|
||||
|
||||
Select.vm.$data._value = ["one", "two"];
|
||||
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"]);
|
||||
});
|
||||
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", () => {
|
||||
it('should set value to null on delete keypress when multiple is false', () => {
|
||||
const Select = selectWithProps({
|
||||
options: ["one", "two", "three"]
|
||||
});
|
||||
options: ['one', 'two', 'three'],
|
||||
})
|
||||
|
||||
Select.vm.$data._value = 'one';
|
||||
Select.vm.$data._value = 'one'
|
||||
|
||||
Select.vm.maybeDeleteValue();
|
||||
expect(Select.vm.selectedValue).toEqual([]);
|
||||
});
|
||||
Select.vm.maybeDeleteValue()
|
||||
expect(Select.vm.selectedValue).toEqual([])
|
||||
})
|
||||
|
||||
it('will not emit input event if value has not changed with backspace', () => {
|
||||
const Select = mountDefault();
|
||||
Select.vm.$data._value = 'one';
|
||||
Select.find({ ref: 'search' }).trigger('keydown.backspace');
|
||||
expect(Select.emitted().input.length).toBe(1);
|
||||
const Select = mountDefault()
|
||||
Select.vm.$data._value = 'one'
|
||||
Select.find({ ref: 'search' }).trigger('keydown.backspace')
|
||||
expect(Select.emitted().input.length).toBe(1)
|
||||
|
||||
Select.find({ ref: 'search' }).trigger('keydown.backspace');
|
||||
Select.find({ ref: 'search' }).trigger('keydown.backspace');
|
||||
expect(Select.emitted().input.length).toBe(1);
|
||||
});
|
||||
Select.find({ ref: 'search' }).trigger('keydown.backspace')
|
||||
Select.find({ ref: 'search' }).trigger('keydown.backspace')
|
||||
expect(Select.emitted().input.length).toBe(1)
|
||||
})
|
||||
|
||||
describe("Clear button", () => {
|
||||
it("should be displayed on single select when value is selected", () => {
|
||||
describe('Clear button', () => {
|
||||
it('should be displayed on single select when value is selected', () => {
|
||||
const Select = selectWithProps({
|
||||
options: ["foo", "bar"],
|
||||
value: "foo"
|
||||
});
|
||||
options: ['foo', 'bar'],
|
||||
value: 'foo',
|
||||
})
|
||||
|
||||
expect(Select.vm.showClearButton).toEqual(true);
|
||||
});
|
||||
expect(Select.vm.showClearButton).toEqual(true)
|
||||
})
|
||||
|
||||
it("should not be displayed on multiple select", () => {
|
||||
it('should not be displayed on multiple select', () => {
|
||||
const Select = selectWithProps({
|
||||
options: ["foo", "bar"],
|
||||
value: "foo",
|
||||
multiple: true
|
||||
});
|
||||
options: ['foo', 'bar'],
|
||||
value: 'foo',
|
||||
multiple: true,
|
||||
})
|
||||
|
||||
expect(Select.vm.showClearButton).toEqual(false);
|
||||
});
|
||||
expect(Select.vm.showClearButton).toEqual(false)
|
||||
})
|
||||
|
||||
it("should remove selected value when clicked", () => {
|
||||
it('should remove selected value when clicked', () => {
|
||||
const Select = selectWithProps({
|
||||
options: ["foo", "bar"],
|
||||
});
|
||||
Select.vm.$data._value = 'foo';
|
||||
options: ['foo', 'bar'],
|
||||
})
|
||||
Select.vm.$data._value = 'foo'
|
||||
|
||||
expect(Select.vm.selectedValue).toEqual(["foo"]);
|
||||
Select.find("button.vs__clear").trigger("click");
|
||||
expect(Select.vm.selectedValue).toEqual(['foo'])
|
||||
Select.find('button.vs__clear').trigger('click')
|
||||
|
||||
expect(Select.emitted().input).toEqual([[null]]);
|
||||
expect(Select.vm.selectedValue).toEqual([]);
|
||||
});
|
||||
expect(Select.emitted().input).toEqual([[null]])
|
||||
expect(Select.vm.selectedValue).toEqual([])
|
||||
})
|
||||
|
||||
it("should be disabled when component is disabled", () => {
|
||||
it('should be disabled when component is disabled', () => {
|
||||
const Select = selectWithProps({
|
||||
options: ["foo", "bar"],
|
||||
value: "foo",
|
||||
disabled: true
|
||||
});
|
||||
options: ['foo', 'bar'],
|
||||
value: 'foo',
|
||||
disabled: true,
|
||||
})
|
||||
|
||||
expect(Select.find("button.vs__clear").attributes().disabled).toEqual(
|
||||
"disabled"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
expect(Select.find('button.vs__clear').attributes().disabled).toEqual(
|
||||
'disabled'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user