blessing-skin-server/resources/assets/tests/js/logout.test.ts
2019-03-25 22:01:57 +08:00

21 lines
460 B
TypeScript

import { logout } from '@/js/logout'
import { post } from '@/js/net'
import { MessageBox } from '@/js/element'
jest.mock('@/js/net')
jest.mock('@/js/element')
test('log out', async () => {
MessageBox.confirm
.mockRejectedValueOnce('cancel')
.mockResolvedValue('confirm')
post.mockResolvedValue({ msg: '' })
await logout()
expect(post).not.toBeCalled()
await logout()
expect(post).toBeCalledWith('/auth/logout')
jest.runAllTimers()
})