blessing-skin-server/resources/assets/tests/scripts/logout.test.ts
2019-11-30 12:01:17 +08:00

20 lines
459 B
TypeScript

import { logout } from '@/scripts/logout'
import { post } from '@/scripts/net'
import { showModal } from '@/scripts/notify'
jest.mock('@/scripts/net')
jest.mock('@/scripts/notify')
test('log out', async () => {
showModal
.mockRejectedValueOnce(null)
.mockResolvedValueOnce({ value: '' })
post.mockResolvedValue({ message: '' })
await logout()
expect(post).not.toBeCalled()
await logout()
expect(post).toBeCalledWith('/auth/logout')
})