Skip to content

Commit

Permalink
add default route test (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
januschung authored Dec 17, 2023
1 parent 508f250 commit 71e8002
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 8 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
17 changes: 14 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,26 @@
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"start": "DISABLE_ESLINT_PLUGIN=true react-scripts start",
"build": "DISABLE_ESLINT_PLUGIN=true react-scripts build",
"test": "DISABLE_ESLINT_PLUGIN=true react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
],
"rules": {
"no-unused-vars": "warn"
},
"overrides": [
{
"files": ["**/*.ts?(x)"],
"rules": {
"max-len": "warn"
}
}
]
},
"browserslist": {
Expand Down
21 changes: 16 additions & 5 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import App from './App';
import PrimarySearchAppBar from './components/SearchBar';
import JobApplicationList from './components/JobApplicationList';

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

jest.mock('./components/SearchBar')
jest.mock('./components/JobApplicationList')

it('Should render Job Application list on default route', async () => {
PrimarySearchAppBar.mockImplementation(() => <div>PrimarySearchAppBarMock</div>)
JobApplicationList.mockImplementation(() => <div>JobApplicationListrMock</div>)
render(<MemoryRouter>
<App />
</MemoryRouter>);
expect(screen.getByText("PrimarySearchAppBarMock")).toBeInTheDocument();
expect(screen.getByText("JobApplicationListrMock")).toBeInTheDocument();
});

0 comments on commit 71e8002

Please sign in to comment.