2024-02-25 19:32:53 +00:00
|
|
|
import { screen } from '@testing-library/vue'
|
|
|
|
import { expect, it } from 'vitest'
|
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
|
|
|
import { authService } from '@/services'
|
|
|
|
import ResetPasswordForm from './ResetPasswordForm.vue'
|
|
|
|
|
|
|
|
new class extends UnitTestCase {
|
|
|
|
protected test () {
|
|
|
|
it('resets password', async () => {
|
|
|
|
const resetMock = this.mock(authService, 'resetPassword').mockResolvedValue(null)
|
2024-04-22 21:04:03 +00:00
|
|
|
const loginMock = this.mock(authService, 'login').mockResolvedValue(null)
|
2024-02-25 19:32:53 +00:00
|
|
|
|
|
|
|
await this.router.activateRoute({
|
|
|
|
path: '_',
|
|
|
|
screen: 'Password.Reset'
|
|
|
|
}, { payload: 'Zm9vQGJhci5jb218bXktdG9rZW4=' })
|
|
|
|
|
|
|
|
this.render(ResetPasswordForm)
|
|
|
|
await this.type(screen.getByPlaceholderText('New password'), 'new-password')
|
|
|
|
await this.user.click(screen.getByRole('button', { name: 'Save' }))
|
|
|
|
|
|
|
|
expect(resetMock).toHaveBeenCalledWith('foo@bar.com', 'new-password', 'my-token')
|
2024-04-22 21:04:03 +00:00
|
|
|
expect(loginMock).toHaveBeenCalledWith('foo@bar.com', 'new-password')
|
2024-02-25 19:32:53 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|