mirror of
https://github.com/tenrok/vue-select.git
synced 2026-06-22 10:30:34 +03:00
add tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { mount, shallowMount } from "@vue/test-utils";
|
import { mount, shallowMount } from "@vue/test-utils";
|
||||||
import VueSelect from "../../src/components/Select.vue";
|
import VueSelect from "../../src/components/Select.vue";
|
||||||
|
import { mountDefault } from '../helpers';
|
||||||
|
|
||||||
describe("VS - Selecting Values", () => {
|
describe("VS - Selecting Values", () => {
|
||||||
let defaultProps;
|
let defaultProps;
|
||||||
@@ -195,7 +196,7 @@ describe("VS - Selecting Values", () => {
|
|||||||
expect(Select.vm.isOptionSelected("foo")).toEqual(true);
|
expect(Select.vm.isOptionSelected("foo")).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("change Event", () => {
|
describe("input Event", () => {
|
||||||
it("will trigger the input event when the selection changes", () => {
|
it("will trigger the input event when the selection changes", () => {
|
||||||
const Select = shallowMount(VueSelect);
|
const Select = shallowMount(VueSelect);
|
||||||
Select.vm.select("bar");
|
Select.vm.select("bar");
|
||||||
@@ -210,4 +211,21 @@ describe("VS - Selecting Values", () => {
|
|||||||
expect(Select.emitted("input")[0]).toEqual([["foo", "bar"]]);
|
expect(Select.emitted("input")[0]).toEqual([["foo", "bar"]]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('selected classes', () => {
|
||||||
|
it("adds the vs__selected class by default", () => {
|
||||||
|
const Select = mountDefault({value: 'one'});
|
||||||
|
expect(Select. contains('.vs__selected')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("can add a custom class using the getSelectedOptionClasses prop", () => {
|
||||||
|
const Select = mountDefault({
|
||||||
|
value: 'one',
|
||||||
|
getSelectedOptionClasses: option => ['vs__selected', `vs__selected--${option}`]
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(Select. contains('.vs__selected')).toBe(true);
|
||||||
|
expect(Select. contains('.vs__selected--one')).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user