mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
by setting up localVue with all required plugins (such as styleguide and vuex) in a separate testSetup file we can avoid doing this individually in all component tests the testSetup is executed before each test suite, so each test file gets a fresh instance of localVue
51 lines
1.0 KiB
JavaScript
51 lines
1.0 KiB
JavaScript
import { mount } from '@vue/test-utils'
|
|
import EnterNonce from './EnterNonce.vue'
|
|
|
|
const localVue = global.localVue
|
|
|
|
describe('EnterNonce ', () => {
|
|
let wrapper
|
|
let Wrapper
|
|
let mocks
|
|
let propsData
|
|
|
|
beforeEach(() => {
|
|
mocks = {
|
|
$t: jest.fn(),
|
|
}
|
|
propsData = {
|
|
email: 'mail@example.org',
|
|
}
|
|
})
|
|
|
|
describe('mount', () => {
|
|
beforeEach(jest.useFakeTimers)
|
|
|
|
Wrapper = () => {
|
|
return mount(EnterNonce, {
|
|
mocks,
|
|
localVue,
|
|
propsData,
|
|
})
|
|
}
|
|
|
|
it('renders an enter nonce form', () => {
|
|
wrapper = Wrapper()
|
|
expect(wrapper.find('form').exists()).toBe(true)
|
|
})
|
|
|
|
describe('after nonce entered', () => {
|
|
beforeEach(() => {
|
|
wrapper = Wrapper()
|
|
wrapper.find('input#nonce').setValue('123456')
|
|
wrapper.find('form').trigger('submit')
|
|
})
|
|
|
|
it('emits `nonceEntered`', () => {
|
|
const expected = [[{ nonce: '123456', email: 'mail@example.org' }]]
|
|
expect(wrapper.emitted('nonceEntered')).toEqual(expected)
|
|
})
|
|
})
|
|
})
|
|
})
|