Skip to content

Commit 18797ac

Browse files
Adding GH Actions
1 parent 57e534e commit 18797ac

File tree

10 files changed

+3374
-2956
lines changed

10 files changed

+3374
-2956
lines changed

.github/workflows/build.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [14.x]
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v2
20+
21+
- name: Set up Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v1
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
26+
- name: Get yarn cache directory path
27+
id: yarn-cache-dir-path
28+
run: echo "::set-output name=dir::$(yarn cache dir)"
29+
30+
- uses: actions/cache@v2
31+
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
32+
with:
33+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
34+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-yarn-
37+
38+
- name: Install dependencies
39+
run: yarn
40+
41+
- name: Test
42+
run: CI=true yarn test
43+
44+
- name: Build
45+
run: yarn build

package.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,26 @@
44
"private": true,
55
"dependencies": {
66
"@fortawesome/fontawesome-free": "^5.11.2",
7-
"@testing-library/jest-dom": "^4.2.4",
8-
"@testing-library/react": "^9.3.2",
9-
"@testing-library/user-event": "^7.1.2",
7+
"@testing-library/jest-dom": "^5.11.4",
8+
"@testing-library/react": "^11.1.0",
9+
"@testing-library/user-event": "^12.1.10",
10+
"@types/jest": "^26.0.15",
11+
"@types/node": "^12.0.0",
12+
"@types/react": "^17.0.0",
13+
"@types/react-dom": "^17.0.0",
14+
"@types/react-router-dom": "^5.3.2",
15+
"axios": ">=0.21.2",
1016
"@types/classnames": "^2.2.10",
11-
"@types/jest": "^24.0.0",
1217
"@types/jquery": "^3.5.1",
13-
"@types/node": "^12.0.0",
14-
"@types/react": "^16.9.0",
15-
"@types/react-dom": "^16.9.0",
16-
"@types/react-router-dom": "^5.1.5",
17-
"axios": "^0.19.0",
1818
"bootstrap": "^5.1.3",
1919
"classnames": "^2.2.6",
2020
"lodash": "^4.17.15",
2121
"moment": "^2.24.0",
22-
"react": "^16.13.1",
23-
"react-dom": "^16.13.1",
24-
"react-router-dom": "^5.2.0",
25-
"react-scripts": "3.4.3",
22+
"react": "^17.0.2",
23+
"react-dom": "^17.0.2",
24+
"react-router-dom": "^5.3.0",
25+
"react-scripts": "4.0.3",
26+
"web-vitals": "^1.0.1",
2627
"typescript": "^4.1.2"
2728
},
2829
"scripts": {

src/App.test.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/components/links/Link.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import Link from './Link';
4+
import { LinkModel} from "../../models/LinkModels";
5+
import { MemoryRouter } from 'react-router-dom';
6+
7+
test('Renders Link', () => {
8+
const link : LinkModel= {id: 1, title: 'sivalabs', url: 'https://sivalabs.in', tags: ['java', 'spring']};
9+
10+
render(<MemoryRouter><Link {...link}/></MemoryRouter>);
11+
const linkElement = screen.getByText(/sivalabs/i);
12+
expect(linkElement).toBeInTheDocument();
13+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import Pagination from './Pagination';
4+
import {LinksModel, LinksPaginationModel} from "../../models/LinkModels";
5+
import {MemoryRouter} from "react-router-dom";
6+
7+
test('Renders Pagination', () => {
8+
const linksModel: LinksModel = {
9+
data: [],
10+
hasNext: false,
11+
hasPrevious: false,
12+
isLast: true,
13+
isFirst: true,
14+
pageNumber: 1,
15+
totalPages: 2,
16+
totalElements: 50
17+
}
18+
const paginationModel : LinksPaginationModel= { page:1, links:linksModel, tag: '', query: ''};
19+
20+
render(<MemoryRouter><Pagination {...paginationModel}/></MemoryRouter>);
21+
const firstLinkElement = screen.getByText(/First/i);
22+
expect(firstLinkElement).toBeInTheDocument();
23+
});

src/components/links/Pagination.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import classNames from "classnames";
33
import {NavLink} from "react-router-dom";
44
import {LinksPaginationModel} from "../../models/LinkModels";
55

6-
const Pagination: React.FC<LinksPaginationModel> = (linksPagination) => {
6+
const Pagination: React.FC<LinksPaginationModel> = (linksPagination) : JSX.Element => {
77
let links = linksPagination.links
88
let firstPageUrl = "/links?page=1";
99
let prevPageUrl = `/links?page=${links.pageNumber-1}`;

src/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ import 'bootstrap/dist/js/bootstrap.bundle.min';
1313
import "./index.css";
1414

1515
ReactDOM.render(
16-
<Router>
17-
<App/>
18-
</Router>,
16+
<React.StrictMode>
17+
<Router>
18+
<App/>
19+
</Router>
20+
</React.StrictMode>,
1921
document.getElementById("root")
2022
);

src/setupTests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
// allows you to do things like:
33
// expect(element).toHaveTextContent(/react/i)
44
// learn more: https://github.com/testing-library/jest-dom
5-
import '@testing-library/jest-dom/extend-expect';
5+
import '@testing-library/jest-dom';

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"resolveJsonModule": true,
1818
"isolatedModules": true,
1919
"noEmit": true,
20-
"jsx": "react"
20+
"jsx": "react-jsx",
21+
"noFallthroughCasesInSwitch": true
2122
},
2223
"include": [
2324
"src"

0 commit comments

Comments
 (0)