Skip to content

Commit 3a6a8c4

Browse files
committed
fix tests after rebase
1 parent 4b7a3c2 commit 3a6a8c4

13 files changed

+414
-401
lines changed

src/components/__tests__/OpenwbBaseAlert.spec.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ import { mount } from "@vue/test-utils";
33
import OpenwbBaseAlert from "../OpenwbBaseAlert.vue";
44

55
describe("OpenwbBaseAlert.vue", () => {
6-
it("adds class props.subtype when passed", () => {
7-
const subtype = "info";
8-
const wrapper = mount(OpenwbBaseAlert, {
9-
props: { subtype },
10-
});
11-
const mainDiv = wrapper.find("div.alert");
12-
expect(mainDiv.classes()).toContain("alert-" + subtype);
13-
});
14-
it("render slot when passed", () => {
15-
const slotContent = "<span>Default slot message</span>";
16-
const wrapper = mount(OpenwbBaseAlert, {
17-
slots: {
18-
default: slotContent,
19-
},
20-
});
21-
const mainDiv = wrapper.find("div.alert");
22-
expect(mainDiv.html()).toContain(slotContent);
23-
});
6+
it("adds class props.subtype when passed", () => {
7+
const subtype = "info";
8+
const wrapper = mount(OpenwbBaseAlert, {
9+
props: { subtype },
10+
});
11+
const mainDiv = wrapper.find("div.alert");
12+
expect(mainDiv.classes()).toContain("alert-" + subtype);
13+
});
14+
it("render slot when passed", () => {
15+
const slotContent = "<span>Default slot message</span>";
16+
const wrapper = mount(OpenwbBaseAlert, {
17+
slots: {
18+
default: slotContent,
19+
},
20+
});
21+
const mainDiv = wrapper.find("div.alert");
22+
expect(mainDiv.html()).toContain(slotContent);
23+
});
2424
});

src/components/__tests__/OpenwbBaseArrayInput.spec.js

+36-34
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,40 @@ import { mount } from "@vue/test-utils";
33
import OpenwbBaseArrayInput from "../OpenwbBaseArrayInput.vue";
44

55
describe("OpenwbBaseArrayInput.vue", () => {
6-
// check title prop
7-
it("render title", () => {
8-
const title = "Array Input Test";
9-
const wrapper = mount(OpenwbBaseArrayInput, {
10-
props: { title },
11-
});
12-
const titleLabel = wrapper.find("label.col-form-label");
13-
expect(titleLabel.html()).toContain(title);
14-
});
15-
// check initial value
16-
it("display initial value", () => {
17-
const modelValue = ["1234", "2345"];
18-
const wrapper = mount(OpenwbBaseArrayInput, {
19-
props: { modelValue },
20-
});
21-
const renderedTagList = wrapper.find(".tagList");
22-
modelValue.forEach((element) => {
23-
expect(renderedTagList.html()).toContain(element);
24-
});
25-
});
26-
// check user input
27-
it("add element", async () => {
28-
const newTag = "1234";
29-
const wrapper = mount(OpenwbBaseArrayInput, {});
30-
const renderedTextInput = wrapper.find("input[type=text]");
31-
await renderedTextInput.setValue(newTag);
32-
const renderedAddButton = wrapper.find(
33-
".input-group-append .input-group-text",
34-
);
35-
await renderedAddButton.trigger("click");
36-
expect(wrapper.emitted("update:modelValue")[0]).toStrictEqual([
37-
[newTag],
38-
]);
39-
});
6+
const title = "Array Input Test";
7+
// check title prop
8+
it("render title", () => {
9+
const wrapper = mount(OpenwbBaseArrayInput, {
10+
props: { title },
11+
});
12+
const titleLabel = wrapper.find("label.col-form-label");
13+
expect(titleLabel.html()).toContain(title);
14+
});
15+
// check initial value
16+
it("display initial value", () => {
17+
const modelValue = ["1234", "2345"];
18+
const wrapper = mount(OpenwbBaseArrayInput, {
19+
props: { title, modelValue },
20+
});
21+
const renderedTagList = wrapper.find(".tagList");
22+
modelValue.forEach((element) => {
23+
expect(renderedTagList.html()).toContain(element);
24+
});
25+
});
26+
// check user input
27+
it("add element", async () => {
28+
const newTag = "1234";
29+
const wrapper = mount(OpenwbBaseArrayInput, {
30+
props: { title },
31+
});
32+
const renderedTextInput = wrapper.find("input[type=text]");
33+
await renderedTextInput.setValue(newTag);
34+
const renderedAddButton = wrapper.find(
35+
".input-group-append .input-group-text",
36+
);
37+
await renderedAddButton.trigger("click");
38+
expect(wrapper.emitted("update:modelValue")[0]).toStrictEqual([
39+
[newTag],
40+
]);
41+
});
4042
});

src/components/__tests__/OpenwbBaseAvatar.spec.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { mount } from "@vue/test-utils";
33
import OpenwbBaseAvatar from "../OpenwbBaseAvatar.vue";
44

55
describe("OpenwbBaseAvatar.vue", () => {
6-
it("render slot when passed", () => {
7-
const slotContent = "!";
8-
const wrapper = mount(OpenwbBaseAvatar, {
9-
slots: {
10-
default: slotContent,
11-
},
12-
});
13-
const mainDiv = wrapper.find("div.avatar");
14-
expect(mainDiv.html()).toContain(slotContent);
15-
});
6+
it("render slot when passed", () => {
7+
const slotContent = "!";
8+
const wrapper = mount(OpenwbBaseAvatar, {
9+
slots: {
10+
default: slotContent,
11+
},
12+
});
13+
const mainDiv = wrapper.find("div.avatar");
14+
expect(mainDiv.html()).toContain(slotContent);
15+
});
1616
});

src/components/__tests__/OpenwbBaseButtonGroupInput.spec.js

+34-34
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,38 @@ import { mount } from "@vue/test-utils";
33
import OpenwbBaseButtonGroupInput from "../OpenwbBaseButtonGroupInput.vue";
44

55
describe("OpenwbBaseButtonGroupInput.vue", () => {
6-
// general constants
7-
const title = "Button Group Test";
8-
const buttons = [
9-
{ buttonValue: 1, text: "Button 1" },
10-
{ buttonValue: 2, text: "Button 2" },
11-
];
12-
// check title prop
13-
it("render title", () => {
14-
const wrapper = mount(OpenwbBaseButtonGroupInput, {
15-
props: { title, buttons },
16-
});
17-
const titleLabel = wrapper.find("label.col-form-label");
18-
expect(titleLabel.html()).toContain(title);
19-
});
20-
// check buttons
21-
it("render buttons", () => {
22-
const modelValue = 2;
23-
const wrapper = mount(OpenwbBaseButtonGroupInput, {
24-
props: { buttons, modelValue },
25-
});
26-
const renderedButtons = wrapper.findAll("label.btn");
27-
expect(renderedButtons[0].classes("active")).toBe(false);
28-
expect(renderedButtons[1].classes("active")).toBe(true);
29-
});
30-
// check user input
31-
it("emit on click", async () => {
32-
const modelValue = 2;
33-
const wrapper = mount(OpenwbBaseButtonGroupInput, {
34-
props: { buttons, modelValue },
35-
});
36-
const renderedButtons = wrapper.findAll("input[type=radio]");
37-
await renderedButtons[0].setValue(1);
38-
expect(wrapper.emitted("update:modelValue")[0]).toStrictEqual([1]);
39-
});
6+
// general constants
7+
const title = "Button Group Test";
8+
const buttons = [
9+
{ buttonValue: 1, text: "Button 1" },
10+
{ buttonValue: 2, text: "Button 2" },
11+
];
12+
// check title prop
13+
it("render title", () => {
14+
const wrapper = mount(OpenwbBaseButtonGroupInput, {
15+
props: { title, buttons },
16+
});
17+
const titleLabel = wrapper.find("label.col-form-label");
18+
expect(titleLabel.html()).toContain(title);
19+
});
20+
// check buttons
21+
it("render buttons", () => {
22+
const modelValue = 2;
23+
const wrapper = mount(OpenwbBaseButtonGroupInput, {
24+
props: { buttons, modelValue },
25+
});
26+
const renderedButtons = wrapper.findAll("label.btn");
27+
expect(renderedButtons[0].classes("active")).toBe(false);
28+
expect(renderedButtons[1].classes("active")).toBe(true);
29+
});
30+
// check user input
31+
it("emit on click", async () => {
32+
const modelValue = 2;
33+
const wrapper = mount(OpenwbBaseButtonGroupInput, {
34+
props: { buttons, modelValue },
35+
});
36+
const renderedButtons = wrapper.findAll("input[type=radio]");
37+
await renderedButtons[0].setValue(1);
38+
expect(wrapper.emitted("update:modelValue")[0]).toStrictEqual([1]);
39+
});
4040
});

src/components/__tests__/OpenwbBaseButtonInput.spec.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import { mount } from "@vue/test-utils";
33
import OpenwbBaseButtonInput from "../OpenwbBaseButtonInput.vue";
44

55
describe("OpenwbBaseButtonInput.vue", () => {
6-
// general constants
7-
const title = "Button Test";
8-
const buttonText= "Test Button";
9-
const buttonSubtype = "success";
10-
// check title prop
11-
it("render title", () => {
12-
const wrapper = mount(OpenwbBaseButtonInput, {
13-
props: { title, buttonText, buttonSubtype },
14-
});
15-
const titleLabel = wrapper.find("label.col-form-label");
16-
expect(titleLabel.html()).toContain(title);
17-
});
6+
// general constants
7+
const title = "Button Test";
8+
const buttonText= "Test Button";
9+
const buttonSubtype = "success";
10+
// check title prop
11+
it("render title", () => {
12+
const wrapper = mount(OpenwbBaseButtonInput, {
13+
props: { title, buttonText, buttonSubtype },
14+
});
15+
const titleLabel = wrapper.find("label.col-form-label");
16+
expect(titleLabel.html()).toContain(title);
17+
});
1818
});

0 commit comments

Comments
 (0)