From 71e8002caec80a6bb2f222e7cdcfa29bb9841bda Mon Sep 17 00:00:00 2001 From: januschung Date: Sun, 17 Dec 2023 12:14:36 -0800 Subject: [PATCH] add default route test (#8) --- .github/workflows/node.js.yml | 31 +++++++++++++++++++++++++++++++ package.json | 17 ++++++++++++++--- src/App.test.js | 21 ++++++++++++++++----- 3 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..7ffbfcd --- /dev/null +++ b/.github/workflows/node.js.yml @@ -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 diff --git a/package.json b/package.json index 4c7cf5a..682447c 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/App.test.js b/src/App.test.js index 1f03afe..7cb294a 100644 --- a/src/App.test.js +++ b/src/App.test.js @@ -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(); - 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(() =>
PrimarySearchAppBarMock
) + JobApplicationList.mockImplementation(() =>
JobApplicationListrMock
) + render( + + ); + expect(screen.getByText("PrimarySearchAppBarMock")).toBeInTheDocument(); + expect(screen.getByText("JobApplicationListrMock")).toBeInTheDocument(); +}); \ No newline at end of file