Skip to content

Commit

Permalink
fix jest fails for HistoryView and GenericElement
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Oct 25, 2023
1 parent 7eb965e commit e3f7bdb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions client/src/components/History/Content/GenericElement.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { mount } from "@vue/test-utils";
import { createPinia } from "pinia";
import { getLocalVue } from "tests/jest/helpers";

import GenericElement from "./GenericElement";

jest.mock("vue-router/composables", () => ({
useRoute: jest.fn(() => ({})),
useRouter: jest.fn(() => ({})),
}));

const localVue = getLocalVue();

describe("GenericElement", () => {
const pinia = createPinia();
let wrapper;

beforeEach(() => {
Expand Down Expand Up @@ -58,6 +61,7 @@ describe("GenericElement", () => {
},
},
localVue,
pinia,
});
});

Expand Down
10 changes: 5 additions & 5 deletions client/src/components/History/HistoryView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ async function createWrapper(localVue, currentUserId, history) {
localVue,
stubs: {
icon: { template: "<div></div>" },
ContentItem: true,
},
provide: {
store: {
Expand Down Expand Up @@ -119,14 +120,13 @@ describe("History center panel View", () => {
// parts of the layout that should be similar for all cases
expectCorrectLayout(wrapper);

// all history items, make sure all show up with hids and names
const historyItems = wrapper.findAll(".content-item");
// make sure all history items show up
const historyItems = wrapper.findAll("contentitem-stub");
expect(historyItems.length).toBe(10);
for (let i = 0; i < historyItems.length; i++) {
const hid = historyItems.length - i;
const itemHeader = historyItems.at(i).find("[data-description='content item header info']");
const headerText = `${hid}: Dataset ${hid}`;
expect(itemHeader.text()).toBe(headerText);
expect(historyItems.at(i).attributes("id")).toBe(`${hid}`);
expect(historyItems.at(i).attributes("name")).toBe(`Dataset ${hid}`);
}
});

Expand Down

0 comments on commit e3f7bdb

Please sign in to comment.