File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,22 @@ test('returs a promise', () => {
48
48
expect ( vm . $bind ( 'item' , document ) instanceof Promise ) . toBe ( true )
49
49
} )
50
50
51
+ test ( 'waits for the data to be set when binding a collection' , async ( ) => {
52
+ collection . add ( { foo : 'foo' } )
53
+ const promise = vm . $bind ( 'items' , collection )
54
+ expect ( vm . items ) . toEqual ( [ ] )
55
+ await promise
56
+ expect ( vm . items ) . toEqual ( [ { foo : 'foo' } ] )
57
+ } )
58
+
59
+ test ( 'waits for the data to be set when binding a document' , async ( ) => {
60
+ document . update ( { foo : 'foo' } )
61
+ const promise = vm . $bind ( 'item' , document )
62
+ expect ( vm . item ) . toEqual ( null )
63
+ await promise
64
+ expect ( vm . item ) . toEqual ( { foo : 'foo' } )
65
+ } )
66
+
51
67
test ( 'rejects the promise when errors' , async ( ) => {
52
68
const fakeOnSnapshot = ( _ , fail ) => {
53
69
fail ( new Error ( 'nope' ) )
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ test('is null if ref does not exist', async () => {
85
85
} )
86
86
} )
87
87
88
- test ( 'unbinds previously bound document' , async ( ) => {
88
+ test ( 'unbinds previously bound document when overwriting a bound ' , async ( ) => {
89
89
const c = collection . doc ( )
90
90
91
91
// Mock c onSnapshot to spy when the callback is called
You can’t perform that action at this time.
0 commit comments