Skip to content

Commit

Permalink
specs for logout route
Browse files Browse the repository at this point in the history
  • Loading branch information
caiokf committed Nov 18, 2019
1 parent 48685be commit 3b44737
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions spec/route.logout.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react'
import { shallow } from 'enzyme'
import { Redirect } from 'react-router-dom'

import LogoutRoute from '../src/route.logout'

describe('Login Route', () => {
let auth0MockResult

beforeEach(() => {
auth0MockResult = {
logout: jest.fn(),
}

window.ReactRouterAuth0Provider = auth0MockResult
})

it('shoul call logout when rendered', () => {
shallow(<LogoutRoute />)

expect(auth0MockResult.logout).toHaveBeenCalled()
})

it('redirects when rendered', () => {
window.ReactRouterAuth0Provider.isLoggedIn = () => true

const wrapper = shallow(<LogoutRoute />)
expect(wrapper.find(Redirect)).toHaveLength(1)
})
})

0 comments on commit 3b44737

Please sign in to comment.