forked from cypress-io/cypress-vue-unit-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global-components-spec.js
43 lines (39 loc) · 1.17 KB
/
global-components-spec.js
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
import MessageList from '../../components/MessageList.vue'
const mountVue = require('../..')
// common utils for MessageList
const getItems = () => cy.get('ul li')
/* eslint-env mocha */
describe('Global components', () => {
// two different components, each gets "numbers" list
// into its property "messages"
const template = `
<div>
<message-list :messages="numbers"/>
<a-list :messages="numbers"/>
</div>
`
// our top level data
const data = () => ({ numbers: ['uno', 'dos'] })
// register same component globally under different names
const components = {
'message-list': MessageList,
'a-list': MessageList
}
// extend Vue with global components
const extensions = {
components
}
beforeEach(mountVue({ template, data }, { extensions }))
it('registers global component', () => {
cy
.window()
.its('Vue')
.invoke('component', 'message-list')
// returns component constructor
// so we can compare with our component's constructor (Ctor)
.should('equal', MessageList._Ctor[0])
})
it('shows two items at the start in both lists', () => {
getItems().should('have.length', 4)
})
})