Skip to content

Commit

Permalink
✅ Setup tests #290 (#289)
Browse files Browse the repository at this point in the history
## Description

This PR setup unit tests.

## Checklist

Please review and check off the following items before submitting your
PR:

 <!-- If yes then add 'x' into '[ ]'  -->

- [x] I have tested my changes to ensure they work as expected
- [ ] I have included documentation for any new features or changes
- [x] I have formatted my code according to the project's style
guidelines
- [x] I have written tests for any new features or changes
- [x] I have run the project's test suite and verified that all tests
pass
- [ ] I have updated the README and any other relevant documentation
- [x] I have checked for any spelling or grammatical errors

---------

Co-authored-by: Priyankar Pal <[email protected]>
  • Loading branch information
Syed-Ali-Abbas-Zaidi and priyankarpal authored Apr 27, 2023
1 parent 0732476 commit 5c127ee
Show file tree
Hide file tree
Showing 13 changed files with 1,083 additions and 42 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Unit Tests

on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Install pnpm
run: |
sudo apt-get update
sudo apt-get -y install nodejs
curl -L https://raw.githubusercontent.com/pnpm/self-installer/master/install.js | PNPM_VERSION=6.16.0 node
- name: Install Dependencies
run: pnpm install

- name: Run Tests
run: pnpm test
10 changes: 10 additions & 0 deletions __tests__/pages/AddYourProjectsGuide.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { describe, expect, test } from "vitest"
import { screen, render } from "@testing-library/react"
import AddYourProjectsGuide from "../../src/pages/AddYourProjectsGuide"

describe("Projects Guide page test", () => {
test("Should render Projects Guide Page", () => {
render(<AddYourProjectsGuide />)
expect(screen.getByText(/Follow these steps to add your projects/i)).toBeTruthy()
})
})
10 changes: 10 additions & 0 deletions __tests__/pages/ContributorsPage.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { describe, expect, test } from "vitest"
import { screen, render } from "@testing-library/react"
import ContributorsPage from "../../src/pages/ContributorsPage"

describe("Contributors Page test", () => {
test("Should render Contributors Page", () => {
render(<ContributorsPage />)
expect(screen.getByText(/Contributors/i)).toBeTruthy()
})
})
15 changes: 15 additions & 0 deletions __tests__/pages/HomePage.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { describe, expect, test } from "vitest"
import { screen, render } from "@testing-library/react"
import { BrowserRouter as Router } from "react-router-dom"
import HomePage from "../../src/pages/HomePage"

describe("HomePage test", () => {
test("Should render Home Page", () => {
render(
<Router>
<HomePage />
</Router>,
)
expect(screen.getByText(/Show your project to the world/i)).toBeTruthy()
})
})
18 changes: 12 additions & 6 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,19 @@ pnpm dev
git checkout -b [name_of_your_new_branch]
```

9. Add your changes.
9. Make sure all the test cases pass

```
pnpm test
```

10. Add your changes.

```diff
git add .
```

10. Add your commits
11. Add your commits

```diff
git commit -m "Your Changes"
Expand All @@ -82,18 +88,18 @@ git commit -m "Your Changes"
> pnpm format
> ```
11. Set upstream command
12. Set upstream command
```diff
git remote add upstream https://github.com/priyankarpal/ProjectsHut.git
```
12. Push your commits
13. Push your commits

```diff
git push -u origin [Your-branch-name]
```

13. Create a PR
14. Create a PR

14. Wait for merge
15. Wait for merge
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"prepare": "husky install",
"lint": "prettier --check .",
"format": "prettier --write .",
"preinstall": "npx only-allow pnpm"
"preinstall": "npx only-allow pnpm",
"test": "vitest"
},
"husky": {
"hooks": {
Expand All @@ -35,6 +36,7 @@
"styled-components": "^5.3.10"
},
"devDependencies": {
"@testing-library/react": "^14.0.0",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.1",
"@vitejs/plugin-react-swc": "^3.3.0",
Expand All @@ -46,9 +48,11 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.32.2",
"husky": "^8.0.3",
"jsdom": "^21.1.1",
"postcss": "^8.4.23",
"prettier": "^2.8.8",
"tailwindcss": "^3.3.2",
"vite": "^4.3.2"
"vite": "^4.3.2",
"vitest": "^0.30.1"
}
}
Loading

1 comment on commit 5c127ee

@vercel
Copy link

@vercel vercel bot commented on 5c127ee Apr 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

projectshut – ./

projectshut-priyankarpal.vercel.app
projectshut.vercel.app
projectshut-git-main-priyankarpal.vercel.app

Please sign in to comment.