-
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.
Merge pull request #51 from Kalkuli/develop
Release Final Sprint
- Loading branch information
Showing
143 changed files
with
3,483 additions
and
12,987 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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,50 @@ | ||
import './services/__mocks__/matchMedia' | ||
import { App, mapStateToProps, mapDispatchToProps } from './App' | ||
import { Route } from 'react-router-dom' | ||
|
||
describe('Testing <App/>', () => { | ||
|
||
const spyOnAddAuthToken = jest.fn() | ||
|
||
let wrapper = null | ||
const props = { | ||
onAddAuthToken: spyOnAddAuthToken, | ||
auth_token: 'token' | ||
} | ||
|
||
beforeEach(() => { | ||
wrapper = shallow(<App {...props}/>) | ||
}) | ||
|
||
it('should dispatch onAddAuthToken', () => { | ||
expect(spyOnAddAuthToken).toHaveBeenCalled() | ||
}) | ||
|
||
it('should guard restrict routes to unloogged users', () => { | ||
wrapper.setProps({ auth_token: null }) | ||
const restrictedRoute = wrapper.find('dashboard') | ||
expect(restrictedRoute.exists()).toBe(false) | ||
}) | ||
|
||
it('should render restrict routes to logged users', () => { | ||
expect(wrapper.find(Route)).toHaveLength(8) | ||
}) | ||
|
||
it('should get a not found when accessing an unknown route', () => { | ||
const notFoundReturn = wrapper.instance().notFoundRoute() | ||
expect(notFoundReturn).toEqual(<h1>Not found</h1>) | ||
}) | ||
|
||
it('should test mapStateToProps for retrieving auth_token', () => { | ||
const initialState = { | ||
auth_token: 'token' | ||
} | ||
expect(mapStateToProps(initialState).auth_token).toMatch('token') | ||
}) | ||
|
||
it('should test mapDispatchToProps for dispatching onAddAuthToken', () => { | ||
const dispatch = jest.fn() | ||
mapDispatchToProps(dispatch).onAddAuthToken() | ||
expect(dispatch.mock.calls[0][0]).toEqual({type: 'ADD_AUTH_TOKEN'}) | ||
}) | ||
}) |
Oops, something went wrong.