|
| 1 | +import sinon from 'sinon' |
1 | 2 | import { describeWithShallowAndMount } from '~resources/utils'
|
2 | 3 |
|
3 | 4 | describeWithShallowAndMount('options.sync', (mountingMethod) => {
|
@@ -46,7 +47,7 @@ describeWithShallowAndMount('options.sync', (mountingMethod) => {
|
46 | 47 | <pre>computed.text: <em>{{ computedText }}</em></pre>
|
47 | 48 | </div>
|
48 | 49 | </div>
|
49 |
| - </div> |
| 50 | + </div> |
50 | 51 | `,
|
51 | 52 | data () {
|
52 | 53 | return {
|
@@ -110,4 +111,38 @@ describeWithShallowAndMount('options.sync', (mountingMethod) => {
|
110 | 111 | done()
|
111 | 112 | })
|
112 | 113 | })
|
| 114 | + |
| 115 | + it('call updated when sync is not false', () => { |
| 116 | + const childComponentSpy = sinon.stub() |
| 117 | + const ChildComponent = { |
| 118 | + template: '<div>{{ foo }}</div>', |
| 119 | + props: ['foo'], |
| 120 | + updated () { |
| 121 | + childComponentSpy() |
| 122 | + } |
| 123 | + } |
| 124 | + const spy = sinon.stub() |
| 125 | + const TestComponent = { |
| 126 | + template: '<div>{{ foo }}<child-component :foo="foo" /></div>', |
| 127 | + data () { |
| 128 | + return { |
| 129 | + foo: 'foo' |
| 130 | + } |
| 131 | + }, |
| 132 | + updated () { |
| 133 | + spy() |
| 134 | + } |
| 135 | + } |
| 136 | + const wrapper = mountingMethod(TestComponent, { |
| 137 | + stubs: { 'child-component': ChildComponent }, |
| 138 | + sync: true |
| 139 | + }) |
| 140 | + expect(spy.notCalled).to.equal(true) |
| 141 | + expect(childComponentSpy.notCalled).to.equal(true) |
| 142 | + expect(wrapper.html()).to.equal('<div>foo<div>foo</div></div>') |
| 143 | + wrapper.vm.foo = 'bar' |
| 144 | + expect(spy.calledOnce).to.equal(true) |
| 145 | + expect(childComponentSpy.calledOnce).to.equal(true) |
| 146 | + expect(wrapper.html()).to.equal('<div>bar<div>bar</div></div>') |
| 147 | + }) |
113 | 148 | })
|
0 commit comments