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

Commit e96281c

Browse files
committed
update mixins test
1 parent ca2991b commit e96281c

File tree

1 file changed

+12
-4
lines changed
  • cypress/component/basic/mixins

1 file changed

+12
-4
lines changed

cypress/component/basic/mixins/spec.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import { mount, mountCallback } from 'cypress-vue-unit-test'
33

44
describe('Mixins', () => {
5+
const template = '<div>mixin test</div>'
6+
57
context('Global mixin', () => {
68
const MyMixin = {
79
// we have to use original Sinon to create a spy
@@ -14,10 +16,13 @@ describe('Mixins', () => {
1416
const extensions = {
1517
mixin,
1618
}
17-
beforeEach(mountCallback({}, { extensions }))
19+
beforeEach(mountCallback({ template }, { extensions }))
1820

1921
it('calls mixin "created" method', () => {
20-
expect(MyMixin.created).to.have.been.calledOnce
22+
// the "created" will be called twice
23+
// 1 - when the test wrapper element made by the Vue test utils is created
24+
// 2 - when the element above we are testing is created
25+
expect(MyMixin.created).to.have.been.calledTwice
2126
})
2227
})
2328

@@ -32,9 +37,12 @@ describe('Mixins', () => {
3237
const extensions = {
3338
mixin,
3439
}
35-
mount({}, { extensions })
40+
mount({ template }, { extensions })
3641
// use the alias to retrieve the stub to check
37-
cy.get('@created').should('have.been.calledOnce')
42+
// the "created" will be called twice
43+
// 1 - when the test wrapper element made by the Vue test utils is created
44+
// 2 - when the element above we are testing is created
45+
cy.get('@created').should('have.been.calledTwice')
3846
})
3947
})
4048
})

0 commit comments

Comments
 (0)