Skip to content

Commit

Permalink
Adjust quota meter jest test
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Jun 1, 2024
1 parent 765bab3 commit 5cdd404
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions client/src/components/Masthead/QuotaMeter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ import { mount } from "@vue/test-utils";
import flushPromises from "flush-promises";
import { getLocalVue } from "tests/jest/helpers";

import { mockFetcher } from "@/api/schema/__mocks__";
import { useUserStore } from "@/stores/userStore";

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, userData: any) {
mockFetcher.path("/api/configuration").method("get").mock({ data: config });
configValues = { ...config };
const pinia = createTestingPinia();
const userStore = useUserStore();
userStore.currentUser = { ...userStore.currentUser, ...userData };
Expand Down Expand Up @@ -66,7 +74,6 @@ describe("QuotaMeter.vue", () => {
const user = { total_disk_usage: 7168 };
const config = { enable_quotas: false };
const wrapper = await createQuotaMeterWrapper(config, user);
console.log(wrapper.html());
expect(wrapper.find("span").text()).toBe("Using 7 KB");
}
{
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Masthead/QuotaMeter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ const variant = computed(() => {
<BProgress :max="100">
<BProgressBar aria-label="Quota usage" :value="usage" :variant="variant" />
</BProgress>
<span v-if="hasQuota">{{ "Usage " + usage.toFixed(0) }}%</span>
<span v-else>{{ "Usage " + totalUsageString }}</span>
<span v-if="hasQuota">{{ "Using " + usage.toFixed(0) }}%</span>
<span v-else>{{ "Using " + totalUsageString }}</span>
</BLink>
</div>
</template>
Expand Down

0 comments on commit 5cdd404

Please sign in to comment.