Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
feat(components/RouteAuth): add RouteAuth tests
Browse files Browse the repository at this point in the history
feat(components/RouteAuth): add RouteAuth tests
  • Loading branch information
Metnew committed Oct 18, 2017
1 parent 49df5e2 commit c824599
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/common/components/addons/RouteAuth/index.test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import {Route, Redirect} from 'react-router-dom'
import RouteAuth from 'components/addons/RouteAuth'
import {shallow} from 'enzyme'
import toJson from 'enzyme-to-json'
import {routes as routing} from 'routing'

const accessToInboxOnly = path => {
Expand All @@ -13,25 +13,24 @@ const accessExceptInbox = path => {

const sampleRouteItem = routing.filter(a => a.component && a.tag)[0]

xdescribe('RouteAuth component', () => {
it('creates <Redirect /> if user dont have access', done => {
describe('RouteAuth component', () => {
it('creates <Redirect /> if user doesn\'t have access', () => {
const gotRedirect = {
...sampleRouteItem,
canAccess: accessExceptInbox,
path: '/inbox'
}
const component = shallow(<RouteAuth {...gotRedirect} />)
done()
expect(component.equals(<Redirect to="/auth" />)).toBe(true)
})

it('creates component if user have access', done => {
it('creates <Route /> if user has access', () => {
const gotComponent = {
...sampleRouteItem,
canAccess: accessToInboxOnly,
path: '/inbox'
}
const component = shallow(<RouteAuth {...gotComponent} />)
console.log(component)
done()
expect(component.equals(<Route {...gotComponent} />)).toBe(true)
})
})

0 comments on commit c824599

Please sign in to comment.