coverage request.spec.js

This commit is contained in:
Ulf Gebhardt 2021-04-25 19:03:50 +02:00
parent f9d5ecec5b
commit 47813b9176
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD

View File

@ -0,0 +1,54 @@
import { config, mount } from '@vue/test-utils'
import request from './request.vue'
const localVue = global.localVue
// config.stubs['sweetalert-icon'] = '<span><slot /></span>'
config.stubs['nuxt-link'] = '<span class="nuxt-link"><slot /></span>'
describe('request.vue', () => {
let wrapper
let mocks
beforeEach(() => {
mocks = {
/* $toast: {
success: jest.fn(),
error: jest.fn(),
}, */
$t: jest.fn(),
$apollo: {
loading: false,
// mutate: jest.fn().mockResolvedValue({ data: { reqestPasswordReset: true } }),
},
/* $router: {
push: jest.fn()
} */
}
})
describe('mount', () => {
const Wrapper = () => {
return mount(request, { mocks, localVue })
}
beforeEach(() => {
wrapper = Wrapper()
})
it('renders', () => {
expect(wrapper.findAll('.ds-form')).toHaveLength(1)
})
it.skip('calls "handlePasswordResetRequested" on submit', async () => {
await jest.useFakeTimers()
await wrapper.find('input#email').setValue('mail@example.org')
await wrapper.findAll('.ds-form').trigger('submit')
await jest.runAllTimers()
expect(wrapper.emitted('handleSubmitted')).toEqual([[{ email: 'mail@example.org' }]])
expect(mocks.$router.push).toHaveBeenCalledWith({
path: 'enter-nonce',
query: { email: 'mail@example.org' },
})
})
})
})