Skip to content

Commit

Permalink
fix front end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaLRussell committed Oct 27, 2023
1 parent b73fe9a commit 0461a0e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions app/static/tests/unit/localStorageManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("localStorageManager for sessions", () => {
});

it("can add session id when basePath is not empty", () => {
localStorageManager.addSessionId("day1", "testInstance", "session3");
localStorageManager.addSessionId("day1", "testInstance","session3");
expect(spyOnGetItem).toHaveBeenCalledTimes(1);
expect(spyOnSetItem).toHaveBeenCalledTimes(1);
expect(spyOnSetItem.mock.calls[0][0]).toBe("testInstance_day1_sessionIds");
Expand All @@ -59,7 +59,7 @@ describe("localStorageManager gets and saves user preferences", () => {

beforeAll(() => {
spyOnGetItem = jest.spyOn(Storage.prototype, "getItem")
.mockReturnValue("{\"showUnlabelledSessions\": false}");
.mockReturnValue("{\"showUnlabelledSessions\": false, \"showDuplicateSessions\": true}");
spyOnSetItem = jest.spyOn(Storage.prototype, "setItem");
});

Expand All @@ -69,7 +69,7 @@ describe("localStorageManager gets and saves user preferences", () => {

it("can get user preferences", () => {
const result = localStorageManager.getUserPreferences();
expect(result).toStrictEqual(mockUserPreferences());
expect(result).toStrictEqual({showUnlabelledSessions: false, showDuplicateSessions: true});
expect(spyOnGetItem).toHaveBeenCalledWith("preferences");
});

Expand All @@ -94,7 +94,7 @@ describe("localStorageManager gets default user preferences", () => {

it("can get default user preferences", () => {
const result = localStorageManager.getUserPreferences();
expect(result).toStrictEqual({ showUnlabelledSessions: true });
expect(result).toStrictEqual({ showUnlabelledSessions: true, showDuplicateSessions: false });
expect(spyOnGetItem).toHaveBeenCalledWith("preferences");
});
});
3 changes: 2 additions & 1 deletion app/static/tests/unit/serialiser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ describe("serialise", () => {
};

const userPreferences = {
showUnlabelledSessions: true
showUnlabelledSessions: true,
showDuplicateSessions: false
};

const basicState: BasicState = {
Expand Down
5 changes: 3 additions & 2 deletions app/static/tests/unit/store/sessions/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,11 @@ describe("SessionsActions", () => {
});

it("GetSessions commits error", async () => {
mockAxios.onGet("/apps/test-app/sessions/metadata?sessionIds=123,456")
mockAxios.onGet("/apps/test-app/sessions/metadata?sessionIds=123,456&removeDuplicates=true")
.reply(500, mockFailure("TEST ERROR"));

const rootState = mockBasicState({ appName: "test-app", appsPath: "apps" });
const userPreferences = mockUserPreferences();
const rootState = mockBasicState({ appName: "test-app", appsPath: "apps", userPreferences });
const commit = jest.fn();
await (actions[SessionsAction.GetSessions] as any)({ commit, rootState, rootGetters });

Expand Down

0 comments on commit 0461a0e

Please sign in to comment.