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

Uads 61/test/setup test cases #12

Merged
merged 4 commits into from
Jun 12, 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
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ jobs:
- name: Install Dependencies
run: yarn

- name: Run Test Cases
run: yarn test

- name: Build the Project
run: yarn build
14 changes: 10 additions & 4 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
"preview": "vite preview",
"test": "vitest"
},
"dependencies": {
"@tanstack/react-query": "^5.18.1",
Expand All @@ -24,8 +25,11 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@testing-library/dom": "^10.1.0",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^16.0.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@vitejs/plugin-react-swc": "^3.5.0",
Expand All @@ -34,9 +38,11 @@
"eslint": "^8.55.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"jsdom": "^24.1.0",
"postcss": "^8.4.34",
"tailwindcss": "^3.4.1",
"typescript": "^5.2.2",
"vite": "^5.0.8"
"vite": "^5.0.8",
"vitest": "^1.6.0"
}
}
17 changes: 17 additions & 0 deletions web/src/pages/__tests__/About.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render, screen } from "@testing-library/react";
import About from "../About";
import '@testing-library/jest-dom'

/*
* Test suite to test if the elements in the About Page are rendered correctly
*/
describe("About Page Rendering", () => {
it("Should display the About page title", () => {
// Render the About component in a simulated DOM
render(<About />);

const message = screen.getByText(/About Us Page/i);

expect(message).toBeInTheDocument();
});
});
17 changes: 17 additions & 0 deletions web/src/pages/__tests__/Event.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render, screen } from "@testing-library/react";
import Event from "../Event";
import '@testing-library/jest-dom'

/*
* Test suite to test if the elements in the Event Page are rendered correctly
*/
describe("Event Page Rendering", () => {
it("Should display the Event page title", () => {
// Render the Event component in a simulated DOM
render(<Event />);

const message = screen.getByText(/Events Page/i);

expect(message).toBeInTheDocument();
});
});
17 changes: 17 additions & 0 deletions web/src/pages/__tests__/Home.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render, screen } from "@testing-library/react";
import Home from "../Home";
import "@testing-library/jest-dom";

/*
* Test suite to test if the elements in the Home Page are rendered correctly
*/
describe("Home Page Rendering", () => {
it("Should display the Home page title", () => {
// Render the About component in a simulated DOM
render(<Home />);

const message = screen.getByText(/Home Page/i);

expect(message).toBeInTheDocument();
});
});
17 changes: 17 additions & 0 deletions web/src/pages/__tests__/SignUp.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render, screen } from "@testing-library/react";
import SignUp from "../SignUp";
import "@testing-library/jest-dom";

/*
* Test suite to test if the elements in the SignUp Page are rendered correctly
*/
describe("SignUp Page Rendering", () => {
it("Should display the SignUp page title", () => {
// Render the About component in a simulated DOM
render(<SignUp />);

const message = screen.getByText(/Sign Up Page/i);

expect(message).toBeInTheDocument();
});
});
17 changes: 17 additions & 0 deletions web/src/pages/__tests__/Sponsor.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { render, screen } from "@testing-library/react";
import Sponsor from "../Sponsor";
import '@testing-library/jest-dom'

/*
* Test suite to test if the elements in the Sponsor Page are rendered correctly
*/
describe("Sponsor Page Rendering", () => {
it("Should display the Sponsor page title", () => {
// Render the Sponsor component in a simulated DOM
render(<Sponsor />);

const message = screen.getByText(/Sponsors Page/i);

expect(message).toBeInTheDocument();
});
});
1 change: 1 addition & 0 deletions web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"types": ["vitest/globals"],

"paths": {
"@utils/*": ["./src/utils/*"],
Expand Down
4 changes: 3 additions & 1 deletion web/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// <reference types="vitest" />

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';

Expand All @@ -13,4 +15,4 @@ export default defineConfig({
'@layouts': '/src/layouts',
},
},
});
});
14 changes: 14 additions & 0 deletions web/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// <reference types="vitest" />
/// <reference types = "vite/client" />

import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
globals: true,
environment: "jsdom",
setupFiles: ["./vitest.setup.ts"],
css: true,

},
});
1 change: 1 addition & 0 deletions web/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "@testing-library/jest-dom";
Loading
Loading