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', () => {
4848 expect ( vm . $bind ( 'item' , document ) instanceof Promise ) . toBe ( true )
4949} )
5050
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+
5167test ( 'rejects the promise when errors' , async ( ) => {
5268 const fakeOnSnapshot = ( _ , fail ) => {
5369 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 () => {
8585 } )
8686} )
8787
88- test ( 'unbinds previously bound document' , async ( ) => {
88+ test ( 'unbinds previously bound document when overwriting a bound ' , async ( ) => {
8989 const c = collection . doc ( )
9090
9191 // Mock c onSnapshot to spy when the callback is called
You can’t perform that action at this time.
0 commit comments