Skip to content

Commit

Permalink
Fix extra test logging and establish abstractions for config mocking.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Nov 20, 2024
1 parent 8e2d02f commit 9315761
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
13 changes: 3 additions & 10 deletions client/src/components/Grid/GridList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,17 @@ import { mount } from "@vue/test-utils";
import flushPromises from "flush-promises";
import { PiniaVuePlugin } from "pinia";
import { getLocalVue } from "tests/jest/helpers";
import { setupMockConfig } from "tests/jest/mockConfig";

import { useConfig } from "@/composables/config";
import Filtering from "@/utils/filtering";

import MountTarget from "./GridList.vue";

jest.useFakeTimers();

jest.mock("composables/config");
useConfig.mockReturnValue({
config: {
value: {
disabled: false,
enabled: true,
},
},
isConfigLoaded: true,
});

setupMockConfig({ disabled: false, enabled: true });

jest.mock("vue-router/composables");

Expand Down
12 changes: 2 additions & 10 deletions client/src/components/Masthead/QuotaMeter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { getFakeRegisteredUser } from "@tests/test-data";
import { mount } from "@vue/test-utils";
import flushPromises from "flush-promises";
import { getLocalVue } from "tests/jest/helpers";
import { setupMockConfig } from "tests/jest/mockConfig";

import { type RegisteredUser } from "@/api";
import { useUserStore } from "@/stores/userStore";
Expand All @@ -11,19 +12,10 @@ import QuotaMeter from "./QuotaMeter.vue";

jest.mock("@/api/schema");

let configValues = { enable_quotas: true };

jest.mock("@/composables/config", () => ({
useConfig: jest.fn(() => ({
config: { value: { ...configValues } },
isConfigLoaded: true,
})),
}));

const localVue = getLocalVue();

async function createQuotaMeterWrapper(config: any, user: RegisteredUser) {
configValues = { ...config };
setupMockConfig(config);
const pinia = createTestingPinia();
const userStore = useUserStore();
userStore.currentUser = user;
Expand Down
11 changes: 2 additions & 9 deletions client/src/components/StsDownloadButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import MockAdapter from "axios-mock-adapter";
import flushPromises from "flush-promises";
import { createPinia } from "pinia";
import { getLocalVue } from "tests/jest/helpers";

import { useServerMock } from "@/api/client/__mocks__";
import { setupMockConfig } from "tests/jest/mockConfig";

import StsDownloadButton from "./StsDownloadButton.vue";

Expand All @@ -22,14 +21,8 @@ const FALLBACK_URL = "http://cow.com/direct_download";
const DOWNLOAD_ENDPOINT = "http://cow.com/prepare_download";
const STORAGE_REQUEST_ID = "moocow1235";

const { server, http } = useServerMock();

async function mountStsDownloadButtonWrapper(config) {
server.use(
http.get("/api/configuration", ({ response }) => {
return response(200).json(config);
})
);
setupMockConfig(config);

const pinia = createPinia();
const wrapper = mount(StsDownloadButton, {
Expand Down

0 comments on commit 9315761

Please sign in to comment.