-
Notifications
You must be signed in to change notification settings - Fork 7
/
Navbar.spec.ts
58 lines (49 loc) · 1.36 KB
/
Navbar.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { mount } from '@vue/test-utils'
import Navbar from '../../src/components/Navbar.vue'
import Signup from '../../src/components/Signup.vue'
import { Store } from '../../src/store'
jest.mock('vue-router', () => ({
useRouter: () => {
return {}
}
}))
describe('Navbar', () => {
it('shows a signup modal via teleport', async () => {
const store = new Store({
posts: {
all: new Map(),
ids: [],
loaded: false
},
authors: {
ids: [],
all: new Map(),
loaded: false,
currentUserId: undefined
}
})
const el = document.createElement('div')
el.id = 'modal'
document.body.appendChild(el)
const wrapper = mount(Navbar, {
attachTo: document.body,
global: {
components: {
RouterLink: {
template: `<div></div>`
}
},
plugins: [
store,
]
}
})
await wrapper.get('[data-test="sign-up"]').trigger('click')
const form = wrapper.getComponent(Signup)
expect(document.body.outerHTML).toContain('The value must be between 10 and 40')
await form.get('#Username').setValue('Username')
await form.get('#Password').setValue('12345678910')
expect(document.body.outerHTML).not.toContain('The value must be between 10 and 40')
await form.trigger('submit.prevent')
})
})