Skip to content

Commit

Permalink
Merge pull request #228 from mrc-ide/mrc-5961
Browse files Browse the repository at this point in the history
mrc-5961 vitest pt 10 unit tests finished! 🎉
  • Loading branch information
M-Kusumgar authored Nov 13, 2024
2 parents 10e1bf7 + 8b8eb9c commit a8a0bb5
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 20.x
- name: Install dependencies
run: npm install -g typescript codecov
- name: Build
Expand Down
12 changes: 8 additions & 4 deletions app/server/tests/controllers/appsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ describe("appsController", () => {
shareNotFound: "",
mathjaxSrc,
defaultLanguage: "en",
enableI18n: false
enableI18n: false,
hotReload: undefined
});
expect(mockStatus).not.toBeCalled();
});
Expand All @@ -104,7 +105,8 @@ describe("appsController", () => {
shareNotFound: "",
mathjaxSrc,
defaultLanguage: "en",
enableI18n: false
enableI18n: false,
hotReload: undefined
});
});

Expand All @@ -130,7 +132,8 @@ describe("appsController", () => {
shareNotFound: "",
mathjaxSrc,
defaultLanguage: "en",
enableI18n: false
enableI18n: false,
hotReload: undefined
});
});

Expand All @@ -154,7 +157,8 @@ describe("appsController", () => {
shareNotFound: "tiny-mouse",
mathjaxSrc,
defaultLanguage: "en",
enableI18n: false
enableI18n: false,
hotReload: undefined
});
});

Expand Down
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 a8a0bb5

Please sign in to comment.