Skip to content

Commit

Permalink
test(AuthService): add unit test for logout
Browse files Browse the repository at this point in the history
test(UserService): add tests for clearUserFromLocalStorage
  • Loading branch information
karrui committed Jun 9, 2021
1 parent ead3fcc commit 4b50c69
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/public/services/__tests__/AuthService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Opaque } from 'type-fest'
import {
AUTH_ENDPOINT,
checkIsEmailAllowed,
logout,
sendLoginOtp,
verifyLoginOtp,
} from '../AuthService'
Expand Down Expand Up @@ -83,4 +84,20 @@ describe('AuthService', () => {
)
})
})

describe('logout', () => {
const EXPECTED_ENDPOINT = `${AUTH_ENDPOINT}/logout`
it('should call endpoint successfully', async () => {
// Arrange
const mockReturn = { status: 200 }
MockAxios.get.mockResolvedValueOnce(mockReturn)

// Act
const actual = await logout()

// Assert
expect(actual).toEqual(mockReturn)
expect(MockAxios.get).toHaveBeenLastCalledWith(EXPECTED_ENDPOINT)
})
})
})

0 comments on commit 4b50c69

Please sign in to comment.