Update UI dependencies, improve tests

for AuthorizedRoute component
This commit is contained in:
viktorstrate
2020-11-02 18:26:34 +01:00
parent 74581ee090
commit 51556437f6
3 changed files with 17693 additions and 876 deletions

18542
ui/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,22 +5,22 @@
"description": "UI app for Photoview",
"dependencies": {
"@babel/preset-env": "^7.12.1",
"@types/react": "^16.9.53",
"@types/react": "^16.9.55",
"babel-plugin-styled-components": "^1.11.1",
"copy-to-clipboard": "^3.3.1",
"downloadjs": "^1.4.7",
"graphql": "^14.7.0",
"parcel-bundler": "^1.12.4",
"graphql": "^15.4.0",
"parcel-bundler": "^1.3.1",
"prop-types": "^15.7.2",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-helmet": "^6.1.0",
"react-lazyload": "^3.1.0",
"react-router-dom": "^5.2.0",
"react-spring": "^8.0.27",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^2.0.1",
"styled-components": "^5.2.0",
"styled-components": "^5.2.1",
"subscriptions-transport-ws": "^0.9.18",
"url-join": "^4.0.1"
},
@@ -40,17 +40,17 @@
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.1",
"babel-jest": "^26.6.2",
"babel-plugin-graphql-tag": "^3.1.0",
"babel-plugin-transform-semantic-ui-react-imports": "^1.4.1",
"eslint": "^7.12.0",
"eslint": "^7.12.1",
"eslint-plugin-jest": "^24.1.0",
"eslint-plugin-jest-dom": "^3.2.4",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^4.3.0",
"jest": "^26.6.1",
"lint-staged": "^10.5.0",
"jest": "^26.6.2",
"lint-staged": "^10.5.1",
"mapbox-gl": "^1.12.0",
"parcel-plugin-sw-cache": "^0.3.1",
"prettier": "^2.1.2",

View File

@@ -7,11 +7,13 @@ import { MemoryRouter, Route } from 'react-router-dom'
import * as authentication from '../../authentication'
jest.mock('../../authentication.js')
describe('AuthorizedRoute component', () => {
const AuthorizedComponent = () => <div>authorized content</div>
test('not logged in', async () => {
authentication.authToken = jest.fn(() => null)
authentication.authToken.mockImplementation(() => null)
render(
<MemoryRouter initialEntries={['/']}>
@@ -24,7 +26,7 @@ describe('AuthorizedRoute component', () => {
})
test('logged in', async () => {
authentication.authToken = jest.fn(() => 'token-here')
authentication.authToken.mockImplementation(() => 'token-here')
render(
<MemoryRouter initialEntries={['/']}>
@@ -34,5 +36,6 @@ describe('AuthorizedRoute component', () => {
)
expect(screen.getByText('authorized content')).toBeInTheDocument()
expect(screen.queryByText('login redirect')).toBeNull()
})
})