UNCLASSIFIED

Commit 39a350a7 authored by Baban Faraj's avatar Baban Faraj
Browse files

Add additional test for more test coverage

parent 4c76b6e6
......@@ -34,7 +34,6 @@ describe("ProjectsSummary", () => {
// assert the component loads without error
expect(wrapper.find(".error").exists()).toBe(false);
});
it("should set panelView true and cardView false", () => {
ProjectService.getProjectsSummary = jest.fn();
......@@ -45,8 +44,7 @@ describe("ProjectsSummary", () => {
state: {
error: {},
projects: {
list: [
],
list: [],
},
},
commit: jest.fn(),
......@@ -62,7 +60,9 @@ describe("ProjectsSummary", () => {
vuetify,
});
wrapper.vm.setPanelView();
expect(wrapper.vm.panelView===true && wrapper.vm.cardView===false).toBeTruthy();
expect(
wrapper.vm.panelView === true && wrapper.vm.cardView === false
).toBeTruthy();
});
it("should set panelView false and cardView true", () => {
......@@ -74,8 +74,7 @@ describe("ProjectsSummary", () => {
state: {
error: {},
projects: {
list: [
],
list: [],
},
},
commit: jest.fn(),
......@@ -91,7 +90,9 @@ describe("ProjectsSummary", () => {
vuetify,
});
wrapper.vm.setCardView();
expect(wrapper.vm.panelView===false && wrapper.vm.cardView===true).toBeTruthy();
expect(
wrapper.vm.panelView === false && wrapper.vm.cardView === true
).toBeTruthy();
});
it("should return only failed jobs from a failed pipeline given a project", () => {
ProjectService.getProjectsSummary = jest.fn();
......@@ -102,8 +103,7 @@ describe("ProjectsSummary", () => {
state: {
error: {},
projects: {
list: [
],
list: [],
},
},
commit: jest.fn(),
......@@ -112,8 +112,23 @@ describe("ProjectsSummary", () => {
localVue,
vuetify,
});
const failedProjectJobs = wrapper.vm.retrieveFailedProjectJobsFromFailedPipeline({ id: "1", links: {}, latestPipeline: {name:"testPipeline",status:"failed",latestPipeline:"",message:"test",jobs:[{name:"e2e-test",status:"failed",link:""},{name:"e2e-test2",status:"passed",link:""}]}, favorite: true });
expect(failedProjectJobs.length===1).toBeTruthy();
const failedProjectJobs =
wrapper.vm.retrieveFailedProjectJobsFromFailedPipeline({
id: "1",
links: {},
latestPipeline: {
name: "testPipeline",
status: "failed",
latestPipeline: "",
message: "test",
jobs: [
{ name: "e2e-test", status: "failed", link: "" },
{ name: "e2e-test2", status: "passed", link: "" },
],
},
favorite: true,
});
expect(failedProjectJobs.length === 1).toBeTruthy();
});
it("should filter by favorited projects", () => {
ProjectService.getProjectsSummary = jest.fn();
......
......@@ -27,6 +27,18 @@ describe("Projects", () => {
wrapper.vm.refreshProjectData();
expect(wrapper.vm.$refs.projectSummary.refreshProjects).toHaveBeenCalled();
});
it("should call setCardView", async () => {
const wrapper = shallowMount(Projects, { store, localVue });
wrapper.vm.$refs.projectSummary.setCardView = jest.fn();
wrapper.vm.cardViewProjects();
expect(wrapper.vm.$refs.projectSummary.setCardView).toHaveBeenCalled();
});
it("should call setPanelView", async () => {
const wrapper = shallowMount(Projects, { store, localVue });
wrapper.vm.$refs.projectSummary.setPanelView = jest.fn();
wrapper.vm.panelViewProjects();
expect(wrapper.vm.$refs.projectSummary.setPanelView).toHaveBeenCalled();
});
it("should call setProjectLoading", async () => {
const wrapper = shallowMount(Projects, { store, localVue });
wrapper.vm.setProjectLoading(true);
......
......@@ -67,7 +67,58 @@ describe("LaunchboardUser", () => {
};
expect(wrapper.vm.showWelcomeMessage).toBe(true);
});
it("should call setCardView", async () => {
const store = new Vuex.Store({
state: {
user: {
user: { name: "mock user", permission: Permission.USER },
},
userPreferences: {
userPreference: {
darkMode: true,
welcomeMessage: true,
},
},
},
});
const wrapper = shallowMount(LaunchboardUser, {
mocks: {
$vuetify: { breakpoint: { xsOnly: true } },
},
vuetify,
store,
localVue,
});
wrapper.vm.$refs.projectSummary.setCardView = jest.fn();
wrapper.vm.cardViewProjects();
expect(wrapper.vm.$refs.projectSummary.setCardView).toHaveBeenCalled();
});
it("should call setPanelView", async () => {
const store = new Vuex.Store({
state: {
user: {
user: { name: "mock user", permission: Permission.USER },
},
userPreferences: {
userPreference: {
darkMode: true,
welcomeMessage: true,
},
},
},
});
const wrapper = shallowMount(LaunchboardUser, {
mocks: {
$vuetify: { breakpoint: { xsOnly: true } },
},
vuetify,
store,
localVue,
});
wrapper.vm.$refs.projectSummary.setPanelView = jest.fn();
wrapper.vm.panelViewProjects();
expect(wrapper.vm.$refs.projectSummary.setPanelView).toHaveBeenCalled();
});
it("should refresh project data", async () => {
const store = new Vuex.Store({
state: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment