@@ -35,8 +35,8 @@ beforeEach(async () => {
35
35
}
36
36
} )
37
37
await tick ( )
38
- // XXX dirty hack until $bind resolves when all refs are bound
39
38
// NOTE should add option for it waitForRefs: true (by default)
39
+ // wait for refs to be ready as well
40
40
await delay ( 5 )
41
41
} )
42
42
@@ -74,8 +74,7 @@ test('binds refs on documents', async () => {
74
74
await c . update ( { foo : 'foo' } )
75
75
await a . update ( { ref : c } )
76
76
77
- // XXX dirty hack until $bind resolves when all refs are bound
78
- // NOTE should add option for it waitForRefs: true (by default)
77
+ // NOTE(1) need to wait because we updated with a ref
79
78
await delay ( 5 )
80
79
81
80
expect ( vm . a ) . toEqual ( {
@@ -92,9 +91,6 @@ test('binds refs nested in documents (objects)', async () => {
92
91
} )
93
92
await vm . $bind ( 'item' , item )
94
93
95
- // NOTE same as above
96
- await delay ( 5 )
97
-
98
94
expect ( vm . item ) . toEqual ( {
99
95
obj : {
100
96
ref : { c : true }
@@ -113,9 +109,6 @@ test('binds refs deeply nested in documents (objects)', async () => {
113
109
} )
114
110
await vm . $bind ( 'item' , item )
115
111
116
- // NOTE same as above
117
- await delay ( 5 )
118
-
119
112
expect ( vm . item ) . toEqual ( {
120
113
obj : {
121
114
nested : {
@@ -146,6 +139,7 @@ test('update inner ref', async () => {
146
139
test ( 'is null if ref does not exist' , async ( ) => {
147
140
await d . update ( { ref : a } )
148
141
142
+ // NOTE see #1
149
143
await delay ( 5 )
150
144
151
145
expect ( vm . d ) . toEqual ( {
@@ -160,24 +154,24 @@ test('unbinds previously bound document when overwriting a bound', async () => {
160
154
const spy = spyOnSnapshotCallback ( c )
161
155
await c . update ( { baz : 'baz' } )
162
156
await d . update ( { ref : c } )
157
+ // NOTE see #1
163
158
await delay ( 5 )
164
159
expect ( spy ) . toHaveBeenCalledTimes ( 1 )
165
160
await c . update ( { baz : 'bar' } )
166
- await delay ( 5 )
167
161
// make sure things are updating correctly
168
162
expect ( vm . d ) . toEqual ( {
169
163
ref : { baz : 'bar' }
170
164
} )
171
165
// we call update twice to make sure our mock works
172
166
expect ( spy ) . toHaveBeenCalledTimes ( 2 )
173
167
await d . update ( { ref : a } )
168
+ // NOTE see #1
174
169
await delay ( 5 )
175
170
176
171
expect ( vm . d ) . toEqual ( {
177
172
ref : null
178
173
} )
179
174
await c . update ( { foo : 'bar' } )
180
- await delay ( 5 )
181
175
182
176
expect ( spy ) . toHaveBeenCalledTimes ( 2 )
183
177
expect ( vm . d ) . toEqual ( {
@@ -192,6 +186,7 @@ test('does not rebind if it is the same ref', async () => {
192
186
const spy = spyOnSnapshot ( c )
193
187
await c . update ( { baz : 'baz' } )
194
188
await d . update ( { ref : c } )
189
+ // NOTE see #1
195
190
await delay ( 5 )
196
191
expect ( spy ) . toHaveBeenCalledTimes ( 1 )
197
192
@@ -324,7 +319,7 @@ test('unbinds when a ref is replaced', async () => {
324
319
} )
325
320
326
321
await d . update ( { ref : a } )
327
- // wait for nested ref update
322
+ // NOTE see #1
328
323
await delay ( 5 )
329
324
expect ( vm . d ) . toEqual ( {
330
325
ref : {
0 commit comments