Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mrc-5961 vitest pt 10 unit tests finished! 🎉 #228

Merged
merged 4 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading