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

Commit

Permalink
feat(addons/RouteAuth): add tests for RouteAuth
Browse files Browse the repository at this point in the history
feat(addons/RouteAuth): add tests for RouteAuth
  • Loading branch information
Metnew committed Sep 10, 2017
1 parent 61d3760 commit cdb5d80
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/common/components/addons/RouteAuth/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,36 @@ import React from 'react'
import RouteAuth from 'components/addons/RouteAuth'
import {shallow} from 'enzyme'
import toJson from 'enzyme-to-json'
import {routes as routing} from 'routing'

const props = {
path: '/',
canAccess: () => ({})
}

const notInboxPath = '/auth'
const inboxPath = '/inbox'
const accessToInboxOnly = path => {
return path === '/inbox'
}
const accessExceptInbox = path => {
return path !== '/inbox'
}

describe('RouteAuth component', () => {
it('creates <Redirect /> if user dont have access', done => {

})

it('creates component if user have access', done => {
const sampleRouteItem = routing.filter(a => a.component && a.tag)[0]

})
const gotRedirect = {
path: inboxPath,
canAccess: accessExceptInbox
}
const component = shallow(<RouteAuth {...gotRedirect} />)
describe('RouteAuth component', () => {
// it('creates <Redirect /> if user dont have access', done => {
// const gotRedirect = {
// ...sampleRouteItem,
// canAccess: accessExceptInbox,
// path: '/inbox'
// }
// const component = shallow(<RouteAuth {...gotRedirect} />)
// done()
// })
//
// it('creates component if user have access', done => {
// const gotComponent = {
// ...sampleRouteItem,
// canAccess: accessToInboxOnly,
// path: '/inbox'
// }
// const component = shallow(<RouteAuth {...gotComponent} />)
// console.log(component)
// done()
// })
})

0 comments on commit cdb5d80

Please sign in to comment.