Skip to content

Commit

Permalink
finish off unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Kusumgar committed Nov 5, 2024
1 parent 5cefc2b commit 2430d9b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions app/static/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export default [
}
},

{
files: ["**/tests/**/*.ts"],
rules: {
"vitest/expect-expect": "off"
}
},

{
...pluginPlaywright.configs['flat/recommended'],
files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import Vuex from "vuex";
import registerTranslations from "../../registerTranslations";
import translate from "../../directive/translate";
import { nextTick } from "vue";
import { Mock } from "vitest";

describe("translate directive", () => {
beforeAll(() => {
console.warn = jest.fn();
console.warn = vi.fn();
});

afterAll(() => {
(console.warn as jest.Mock).mockClear();
(console.warn as Mock).mockClear();
});

const TranslateAttributeTest = {
Expand Down Expand Up @@ -243,7 +244,7 @@ describe("translate directive", () => {
}
});
expect(rendered.find("h4").text()).toBe("");
expect((console.warn as jest.Mock).mock.calls[0][0]).toBe("v-translate directive declared without a value");
expect((console.warn as Mock).mock.calls[0][0]).toBe("v-translate directive declared without a value");
});

it("removes watcher on unbind", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { shallowMount, mount } from "@vue/test-utils";
import LanguageSwitcher from "../../src/LanguageSwitcher.vue";

describe("languageSwitcher component", () => {
const mockUpdateLanguage = jest.fn();
const mockUpdateLanguage = vi.fn();

const createStore = (enableI18n: boolean) => {
return new Vuex.Store({
Expand Down
4 changes: 2 additions & 2 deletions app/static/translationPackage/tests/store/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ describe("Language actions", () => {
});

it("UpdateLanguage commits change language mutation and i18next function", async () => {
const commit = jest.fn();
const spyChangeLanguage = jest.spyOn(i18next, "changeLanguage");
const commit = vi.fn();
const spyChangeLanguage = vi.spyOn(i18next, "changeLanguage");
await (actions[LanguageAction.UpdateLanguage] as any)({ commit }, "fr");
expect(commit).toBeCalledTimes(1);
expect(commit.mock.calls[0][0]).toBe(LanguageStateMutation.ChangeLanguage);
Expand Down

0 comments on commit 2430d9b

Please sign in to comment.