This repository has been archived by the owner on Feb 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#104): finished App component test cases
- Loading branch information
Andreas Gasser
committed
Apr 17, 2019
1 parent
5223f0f
commit 9d500bb
Showing
5 changed files
with
8,868 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* global testUtils */ | ||
import React from 'react'; | ||
import { act } from 'react-dom/test-utils'; | ||
import toJson from 'enzyme-to-json'; | ||
import 'jest-styled-components'; | ||
|
||
import { mount } from 'enzyme'; | ||
|
||
import NotFound from '../NotFound'; | ||
|
||
describe('NotFound test suite', () => { | ||
const initialProps = { | ||
location: { | ||
pathname: '/pathname', | ||
}, | ||
}; | ||
|
||
const getNotFound = (props) => mount( | ||
<NotFound | ||
{...initialProps} | ||
/> | ||
); | ||
|
||
it('should render NotFound', () => { | ||
const wrapper = getNotFound(); | ||
expect(wrapper).toBeTruthy(); | ||
|
||
expect(toJson(wrapper)).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import toJson from 'enzyme-to-json'; | ||
import 'jest-styled-components'; | ||
|
||
import { MemoryRouter } from 'react-router-dom'; | ||
|
||
import { mount } from 'enzyme'; | ||
|
||
import Privacy from '../Privacy'; | ||
|
||
describe('Privacy test suite', () => { | ||
const getPrivacy = (props) => mount( | ||
<MemoryRouter> | ||
<Privacy /> | ||
</MemoryRouter> | ||
); | ||
|
||
it('should render', () => { | ||
const wrapper = getPrivacy(); | ||
expect(wrapper).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* global testUtils */ | ||
import React from 'react'; | ||
import * as ReactRouterDom from 'react-router-dom'; | ||
|
||
import { mount } from 'enzyme'; | ||
|
||
import PrivateRoute from '../PrivateRoute'; | ||
|
||
describe('PrivateRoute test suite', () => { | ||
let reactRouterDomRedirectMock; | ||
beforeAll(() => { | ||
// orgRedirect = Redirect | ||
reactRouterDomRedirectMock = jest.spyOn(ReactRouterDom, 'Redirect') | ||
.mockImplementation(() => <p>redirect</p>); | ||
}); | ||
|
||
afterAll(() => { | ||
reactRouterDomRedirectMock.resetMock(); | ||
}); | ||
|
||
const DummyComponent = () => <h1>Test Heading</h1>; | ||
|
||
const getPrivateRoute = (props) => mount( | ||
<ReactRouterDom.MemoryRouter> | ||
<PrivateRoute {...props} /> | ||
</ReactRouterDom.MemoryRouter> | ||
); | ||
|
||
const initialProps = { | ||
component: DummyComponent, | ||
isAuthenticated: true, | ||
}; | ||
|
||
it('should render component if authenticated', () => { | ||
const wrapper = getPrivateRoute(initialProps); | ||
const component = mount(<DummyComponent />); | ||
expect(wrapper.html()).toEqual(component.html()); | ||
}); | ||
|
||
it('should render component if not authenticated', () => { | ||
const wrapper = getPrivateRoute({ | ||
...initialProps, | ||
isAuthenticated: false, | ||
}); | ||
expect(wrapper.html()).toEqual('<p>redirect</p>'); | ||
}); | ||
}); |
Oops, something went wrong.