CSR-803 ish: added unit tests / cleaned up some unit tests
This commit is contained in:
parent
36721ef7ee
commit
55c67333bc
4 changed files with 52 additions and 43 deletions
|
|
@ -2,14 +2,6 @@ import { shallowMount, mount } from "@vue/test-utils";
|
|||
import buttonQuestion from "@/common-components/button-question/button-question";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
|
||||
jest.mock(
|
||||
"@/store",
|
||||
() => {
|
||||
return {};
|
||||
},
|
||||
{ virtual: true }
|
||||
);
|
||||
|
||||
describe("buttonQuestion.vue", () => {
|
||||
it("Should show overflow classes on fieldset if isOverflowScrollable is true", () => {
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ describe("dropdownQuestion.vue", () => {
|
|||
mixins: [mockMixin],
|
||||
});
|
||||
|
||||
wrapper.getCmsContent = jest.fn();
|
||||
|
||||
// Act
|
||||
const select = wrapper.find("select");
|
||||
|
||||
|
|
|
|||
|
|
@ -4,89 +4,77 @@ import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
|||
import { nextTick } from "vue";
|
||||
|
||||
describe("buttonMain.vue", () => {
|
||||
it("Should return btn-primary class", async () => {
|
||||
// Act
|
||||
it("Should return btn-primary class", () => {
|
||||
// Arrange/Act
|
||||
const wrapper = shallowMount(
|
||||
buttonMain,
|
||||
setupMocks({
|
||||
propsData: {
|
||||
props: {
|
||||
isPrimary: true,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
// Assert
|
||||
const button = wrapper.find("button");
|
||||
|
||||
// Expect
|
||||
|
||||
// Assert
|
||||
expect(button.attributes("class")).toContain("btn-primary");
|
||||
});
|
||||
|
||||
it("Should return aria-disabled state", async () => {
|
||||
// Act
|
||||
it("Should return aria-disabled state", () => {
|
||||
// Arrange/Act
|
||||
const wrapper = shallowMount(
|
||||
buttonMain,
|
||||
setupMocks({
|
||||
propsData: {
|
||||
props: {
|
||||
isDisabled: true,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
// Assert
|
||||
const button = wrapper.find("button");
|
||||
|
||||
// Expect
|
||||
// Assert
|
||||
expect(button.attributes()["aria-disabled"]).toEqual("true");
|
||||
});
|
||||
|
||||
it("Should return loader color", async () => {
|
||||
// Act
|
||||
// Arrange
|
||||
const wrapper = shallowMount(
|
||||
buttonMain,
|
||||
setupMocks({
|
||||
propsData: {
|
||||
props: {
|
||||
loaderColor: "blue",
|
||||
loaderEnabled: true,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
// Assert
|
||||
|
||||
const label = wrapper.find("label");
|
||||
|
||||
// Act
|
||||
wrapper.vm.clicked();
|
||||
|
||||
await nextTick();
|
||||
|
||||
|
||||
// Assert
|
||||
const loader = wrapper.find("loader-stub");
|
||||
|
||||
expect(loader.attributes("class")).toContain("blue");
|
||||
});
|
||||
|
||||
it("Should return loader position", async () => {
|
||||
// Act
|
||||
// Arrange
|
||||
const wrapper = shallowMount(
|
||||
buttonMain,
|
||||
setupMocks({
|
||||
propsData: {
|
||||
props: {
|
||||
loaderPosition: "right",
|
||||
loaderEnabled: true,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
// Assert
|
||||
|
||||
const label = wrapper.find("label");
|
||||
|
||||
|
||||
// Act
|
||||
wrapper.vm.clicked();
|
||||
|
||||
await nextTick();
|
||||
|
||||
|
||||
// Assert
|
||||
const loader = wrapper.find("loader-stub");
|
||||
|
||||
expect(loader.attributes("class")).toContain("right");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1 +1,32 @@
|
|||
test.todo("some test to be written in the future");
|
||||
import { shallowMount, mount } from "@vue/test-utils";
|
||||
import loader from "./loader";
|
||||
|
||||
describe("loader.vue", () => {
|
||||
test("if it rendered the HTML element with class", () => {
|
||||
// Arrange/Act
|
||||
const wrapper = shallowMount(loader, {
|
||||
props: {},
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(wrapper.find('div').exists()).toBeTruthy();
|
||||
expect(wrapper.find('.loader').exists()).toBeTruthy();
|
||||
});
|
||||
|
||||
test("if it correctly passed props", () => {
|
||||
// Arrange/Act
|
||||
const wrapper = shallowMount(loader, {
|
||||
props: {
|
||||
loaderColor: "blue",
|
||||
loaderPosition: "left"
|
||||
},
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(wrapper.props()).toMatchObject({
|
||||
loaderColor: "blue",
|
||||
loaderPosition: "left",
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue