Skip to content
This repository was archived by the owner on Dec 12, 2020. It is now read-only.

Commit 879ffc9

Browse files
committed
ported more tutorial tests
1 parent 7e0d5a7 commit 879ffc9

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

cypress/integration/message-spec.js

+23
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,27 @@ describe('Message', () => {
4747
})
4848
})
4949
})
50+
51+
describe('Events', () => {
52+
it('calls handleClick when click on message', () => {
53+
// need to spy on the _original_ method before it gets
54+
// passed to the Vue.extend and gets into private closuer
55+
const spy = cy.spy(Message.methods, 'handleClick')
56+
createCmp({ message: 'Cat' })
57+
cy.get('.message').click().then(() => {
58+
expect(spy).to.be.calledOnce
59+
})
60+
})
61+
62+
it('triggers a message-clicked event clicked', () => {
63+
createCmp({ message: 'Cat' }).then(() => {
64+
const stub = cy.spy()
65+
Cypress.vue.$on('message-clicked', stub)
66+
cy.get('.message').click().then(() => {
67+
expect(stub).to.be.called.once
68+
expect(stub).to.be.calledWith('Cat')
69+
})
70+
})
71+
})
72+
})
5073
})

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ const mountVue = (component, optionsOrProps = {}) => () => {
164164
Cypress.vue = new Vue(component).$mount('#app')
165165
copyStyles(component)
166166
}
167+
168+
return Cypress.vue
167169
})
168170
}
169171

0 commit comments

Comments
 (0)