CSR-803 ish: added unit tests / cleaned up some unit tests

This commit is contained in:
Adam Caouette 2022-12-21 11:22:29 -05:00
parent 36721ef7ee
commit 55c67333bc
4 changed files with 52 additions and 43 deletions

View file

@ -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

View file

@ -23,8 +23,6 @@ describe("dropdownQuestion.vue", () => {
mixins: [mockMixin],
});
wrapper.getCmsContent = jest.fn();
// Act
const select = wrapper.find("select");

View file

@ -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");
});
});

View file

@ -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",
});
});
});