Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of unit tests for FirstStep.js #138

Merged
merged 3 commits into from
Mar 18, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions tests/unit/FirstStep.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { mount } from "@vue/test-utils";
import FirstStep from "@/Components/FirstStep.vue";

describe("FirstStep.vue", () => {
const wrapper = mount(FirstStep);
it("Has the main div tag", () => {
expect(wrapper.contains(".step-content")).toBe(true);
});

it("renders without any errors", () => {
expect(wrapper.isVueInstance()).toBeTruthy();
});

it("Checks if the cardtext function return the correct answer when selected is true", () => {
wrapper.setProps({
selected: true
});

expect(wrapper.vm.cardText).toBe("stepper.FS.selected");
});

it("Checks if the cardtext function return the correct answer when selected is false", () => {
wrapper.setProps({
selected: false
});

expect(wrapper.vm.cardText).toBe("stepper.FS.not-selected");
});

it("Checks if the yesText function returns correct answer", () => {
Tanmay1201 marked this conversation as resolved.
Show resolved Hide resolved
expect(wrapper.vm.yesText).toBe("stepper.FS.selected");
});

it("Checks if the yesText function returns correct answer", () => {
expect(wrapper.vm.noText).toBe("stepper.FS.not-selected");
});

it("Checks if the yesSelected function returns the correct boolean when selected is true", () => {
wrapper.setProps({
selected: true
});
expect(wrapper.vm.yesSelected).toBe("selected");
});

it("Checks if the yesSelected function returns the correct boolean when selected is false", () => {
wrapper.setProps({
selected: false
});
expect(wrapper.vm.yesSelected).toBe("not-selected");
});

it("Checks if the get function in radio returns the correct value when selected is undefined", () => {
wrapper.setProps({
selected: undefined
});
expect(wrapper.vm.radio).toBe(undefined);
});

it("Checks if the get function in radio returns the correct value when selected is yes", () => {
wrapper.setData({
selected: "yes"
});
expect(wrapper.vm.radio).toBe("yes");
});

it("Checks if the noSelected function returns the correct boolean when selected is true", () => {
wrapper.setProps({
selected: true
});
expect(wrapper.vm.noSelected).toBe("not-selected");
});

it("Checks if the noSelected function returns the correct boolean when selected is false", () => {
wrapper.setProps({
selected: false
});
expect(wrapper.vm.noSelected).toBe("selected");
});
});