Skip to content

Commit

Permalink
test(ui): mise en place des tests ui
Browse files Browse the repository at this point in the history
  • Loading branch information
gBusato committed Dec 19, 2024
1 parent bbf9d81 commit 6ba7e5e
Show file tree
Hide file tree
Showing 7 changed files with 495 additions and 8 deletions.
8 changes: 8 additions & 0 deletions docs/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@
- [Lire la doc développement](./developpement/pre-requesites.md)
- postgresql@15 (pour macos : `brew install postgresql@15`)
- Lancer `yarn test` à la racine

Pour lancer des tests sur un projet en particulier :

- Lancer `yarn vitest --project ui|shared|server-unit|server-integration`

Il est possible de lancer plusieurs projets en même temps :

- Lancer `yarn vitest --project ui --project shared`
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
],
"dependencies": {
"@sentry/cli": "^2.37.0",
"@vitejs/plugin-react": "^4.3.4",
"dotenv": "^16.4.5",
"eslint-plugin-react": "^7.37.1",
"global": "4.4.0",
Expand Down
7 changes: 6 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,18 @@
"devDependencies": {
"@chakra-ui/cli": "^2.5.5",
"@iconify/react": "^4.1.1",
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.1.0",
"@tsconfig/next": "^2.0.3",
"@types/iframe-resizer": "^3.5.13",
"@types/node": "^20.17.2",
"@types/qs": "^6.9.16",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.4",
"dotenv": "^16.4.5",
"type-fest": "^4.26.1"
"jsdom": "^25.0.1",
"type-fest": "^4.26.1",
"vitest": "^2.1.3"
}
}
15 changes: 15 additions & 0 deletions ui/utils/__tests__/formatUtils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { describe, expect, it } from "vitest";

import { formatBoolean } from "@/utils/formatUtils";

describe("formatBoolean", () => {
it("doit retourner 'Oui' si la valeur est true", () => {
expect(formatBoolean(true)).toBe("Oui");
});
it("doit retourner 'Non' si la valeur est false", () => {
expect(formatBoolean(false)).toBe("Non");
});
it("doit retourner 'Non' si la valeur est undefined", () => {
expect(formatBoolean(undefined)).toBe("Non");
});
});
12 changes: 12 additions & 0 deletions ui/utils/__tests__/isEmoji.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { describe, expect, test } from "vitest";

import { isEmoji } from "@/utils/isEmoji";

describe("isEmoji", () => {
test("doit retourner true si l'emoji est un emoji", () => {
expect(isEmoji("👍")).toBe(true);
});
test("doit retourner false si la valeur n'est pas un emoji", () => {
expect(isEmoji("test")).toBe(false);
});
});
13 changes: 12 additions & 1 deletion vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { resolve } from "node:path";

import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";
import { defineWorkspace } from "vitest/config";

Expand Down Expand Up @@ -45,7 +46,6 @@ export default defineWorkspace([
},
},
},
// Tests unitaires shared
{
plugins: [tsconfigPaths()],
test: {
Expand All @@ -60,4 +60,15 @@ export default defineWorkspace([
},
},
},
{
plugins: [tsconfigPaths(), react()],
test: {
name: "ui",
root: "./ui",
include: ["./**/*.test.ts"],
clearMocks: true,
environment: "jsdom",
},
resolve: {},
},
]);
Loading

0 comments on commit 6ba7e5e

Please sign in to comment.