File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,41 @@ describe('setData', () => {
16
16
expect ( wrapper . html ( ) ) . toContain ( 'qux' )
17
17
} )
18
18
19
+ // This was a problem in V1
20
+ // See: https://github.com/vuejs/vue-test-utils/issues/1756
21
+ // Making sure it does not regress here.
22
+ it ( 'triggers a watcher' , async ( ) => {
23
+ const Comp = {
24
+ template : `<div />` ,
25
+ data ( ) {
26
+ return {
27
+ myObject : {
28
+ key : 'value'
29
+ } ,
30
+ watchCounter : 0
31
+ }
32
+ } ,
33
+ watch : {
34
+ myObject : {
35
+ immediate : true ,
36
+ handler ( ) {
37
+ this . watchCounter += 1
38
+ }
39
+ }
40
+ }
41
+ }
42
+
43
+ const initial = 'value'
44
+ const expected = 'something else'
45
+ const wrapper = mount ( Comp )
46
+ expect ( wrapper . vm . myObject . key ) . toBe ( initial )
47
+ expect ( wrapper . vm . watchCounter ) . toBe ( 1 )
48
+
49
+ await wrapper . setData ( { myObject : { key : expected } } )
50
+ expect ( wrapper . vm . myObject . key ) . toEqual ( expected )
51
+ expect ( wrapper . vm . watchCounter ) . toBe ( 2 )
52
+ } )
53
+
19
54
it ( 'causes nested nodes to re-render' , async ( ) => {
20
55
const Component = {
21
56
template : `<div><div v-if="show" id="show">Show</div></div>` ,
You can’t perform that action at this time.
0 commit comments