forked from openWB/openwb-ui-settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenwbBaseCheckboxInput.spec.js
61 lines (60 loc) · 1.94 KB
/
OpenwbBaseCheckboxInput.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { describe, it, expect } from "vitest";
import { shallowMount } from "@vue/test-utils";
import OpenwbBaseCheckboxInput from "../OpenwbBaseCheckboxInput.vue";
describe("OpenwbBaseCheckboxInput.vue", () => {
// check title prop
it("render title", () => {
const title = "Checkbox Test";
const wrapper = shallowMount(OpenwbBaseCheckboxInput, {
props: { title },
});
const titleLabel = wrapper.find("label.col-form-label");
expect(titleLabel.html()).toContain(title);
});
// check help slot
it("show help symbol", () => {
const helpContent = "This is our help text.";
const wrapper = shallowMount(OpenwbBaseCheckboxInput, {
slots: {
help: helpContent,
},
});
const titleLabel = wrapper.find("label.col-form-label");
expect(titleLabel.html()).toContain("question-circle");
});
it("show help slot when title is clicked", async () => {
const title = "Button Group Test";
const helpContent = "This is our help text.";
const wrapper = shallowMount(OpenwbBaseCheckboxInput, {
props: { title },
slots: {
help: helpContent,
},
});
const titleLabel = wrapper.find("label.col-form-label");
expect(wrapper.find("span.alert.alert-info").exists()).toBe(false);
await titleLabel.trigger("click");
expect(wrapper.find("span.alert.alert-info").html()).toContain(
helpContent,
);
});
// check buttons
it("render checkbox", () => {
const modelValue = true;
const wrapper = shallowMount(OpenwbBaseCheckboxInput, {
props: { modelValue },
});
const renderedCheckbox = wrapper.find("input[type=checkbox]");
expect(renderedCheckbox.exists()).toBe(true);
});
// check user input
it("emit on click", async () => {
const modelValue = false;
const wrapper = shallowMount(OpenwbBaseCheckboxInput, {
props: { modelValue },
});
const renderedCheckbox = wrapper.find("input[type=checkbox]");
await renderedCheckbox.setValue(true);
expect(wrapper.emitted("update:modelValue")[0]).toStrictEqual([true]);
});
});