Skip to content

docs: Add window.localStorage.remove('token') statement to afterEach() in tests/login.js file #709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ should be installed as one of your project's `devDependencies`:
```
npm install --save-dev @testing-library/react
```

or

for installation via [yarn](https://classic.yarnpkg.com/en/)

```
yarn add --dev @testing-library/react
```
Expand Down Expand Up @@ -283,11 +285,14 @@ import Login from '../login'
const server = setupServer(
rest.post('/api/login', (req, res, ctx) => {
return res(ctx.json({token: 'fake_user_token'}))
})
}),
)

beforeAll(() => server.listen())
afterEach(() => server.resetHandlers())
afterEach(() => {
server.resetHandlers()
window.localStorage.removeItem('token')
})
afterAll(() => server.close())

test('allows the user to login successfully', async () => {
Expand Down Expand Up @@ -318,11 +323,8 @@ test('handles server exceptions', async () => {
// mock the server error response for this test suite only.
server.use(
rest.post('/', (req, res, ctx) => {
return res(
ctx.status(500),
ctx.json({message: 'Internal server error'}),
)
})
return res(ctx.status(500), ctx.json({message: 'Internal server error'}))
}),
)

render(<Login />)
Expand Down Expand Up @@ -591,6 +593,7 @@ Thanks goes to these people ([emoji key][emojis]):

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors][all-contributors] specification.
Expand Down