@@ -62,86 +62,24 @@ describe('DatabaseBuilder', () => {
6262 resource : 'projects/_/instances/subdomains/refs/users' ,
6363 } as any ) ;
6464 } ) ;
65- } ) ;
66-
67- describe ( '#onCreate()' , ( ) => {
68- it ( 'should return "ref.create" as the event type' , ( ) => {
69- let eventType = database . ref ( 'foo' ) . onCreate ( ( ) => null ) . __trigger . eventTrigger . eventType ;
70- expect ( eventType ) . to . eq ( 'providers/google.firebase.database/eventTypes/ref.create' ) ;
71- } ) ;
72-
73- it ( 'should construct a proper resource path' , ( ) => {
74- let resource = database . ref ( 'foo' ) . onCreate ( ( ) => null ) . __trigger . eventTrigger . resource ;
75- expect ( resource ) . to . eq ( 'projects/_/instances/subdomain/refs/foo' ) ;
76- } ) ;
7765
78- it ( 'should return a handler that emits events with a proper DeltaSnapshot ' , ( ) => {
79- let handler = database . ref ( '/users/{id}' ) . onCreate ( event => {
80- expect ( event . data . val ( ) ) . to . deep . equal ( { foo : 'bar' } ) ;
66+ it ( 'should interpolate params until the server does it ' , ( ) => {
67+ let handler = database . ref ( '/users/{id}' ) . onWrite ( event => {
68+ expect ( event . resource ) . to . equal ( 'projects/_/instances/subdomain/refs/users/aUserId' ) ;
8169 } ) ;
8270
8371 return handler ( {
8472 data : {
8573 data : null ,
86- delta : { foo : 'bar' } ,
74+ delta : 'hello' ,
8775 } ,
88- resource : 'projects/_/instances/subdomains/refs/users' ,
89- } as any ) ;
90- } ) ;
91- } ) ;
92-
93- describe ( '#onUpdate()' , ( ) => {
94- it ( 'should return "ref.update" as the event type' , ( ) => {
95- let eventType = database . ref ( 'foo' ) . onUpdate ( ( ) => null ) . __trigger . eventTrigger . eventType ;
96- expect ( eventType ) . to . eq ( 'providers/google.firebase.database/eventTypes/ref.update' ) ;
97- } ) ;
98-
99- it ( 'should construct a proper resource path' , ( ) => {
100- let resource = database . ref ( 'foo' ) . onUpdate ( ( ) => null ) . __trigger . eventTrigger . resource ;
101- expect ( resource ) . to . eq ( 'projects/_/instances/subdomain/refs/foo' ) ;
102- } ) ;
103-
104- it ( 'should return a handler that emits events with a proper DeltaSnapshot' , ( ) => {
105- let handler = database . ref ( '/users/{id}' ) . onUpdate ( event => {
106- expect ( event . data . val ( ) ) . to . deep . equal ( { foo : 'bar' } ) ;
107- } ) ;
108-
109- return handler ( {
110- data : {
111- data : null ,
112- delta : { foo : 'bar' } ,
76+ resource : 'projects/_/instances/subdomain/refs/users/{id}' ,
77+ params : {
78+ id : 'aUserId' ,
11379 } ,
114- resource : 'projects/_/instances/subdomains/refs/users' ,
115- } as any ) ;
116- } ) ;
117- } ) ;
118-
119- describe ( '#onDelete()' , ( ) => {
120- it ( 'should return "ref.delete" as the event type' , ( ) => {
121- let eventType = database . ref ( 'foo' ) . onDelete ( ( ) => null ) . __trigger . eventTrigger . eventType ;
122- expect ( eventType ) . to . eq ( 'providers/google.firebase.database/eventTypes/ref.delete' ) ;
123- } ) ;
124-
125- it ( 'should construct a proper resource path' , ( ) => {
126- let resource = database . ref ( 'foo' ) . onDelete ( ( ) => null ) . __trigger . eventTrigger . resource ;
127- expect ( resource ) . to . eq ( 'projects/_/instances/subdomain/refs/foo' ) ;
128- } ) ;
129-
130- it ( 'should return a handler that emits events with a proper DeltaSnapshot' , ( ) => {
131- let handler = database . ref ( '/users/{id}' ) . onDelete ( event => {
132- expect ( event . data . val ( ) ) . to . deep . equal ( { foo : 'bar' } ) ;
13380 } ) ;
134-
135- return handler ( {
136- data : {
137- data : null ,
138- delta : { foo : 'bar' } ,
139- } ,
140- resource : 'projects/_/instances/subdomains/refs/users' ,
141- } as any ) ;
14281 } ) ;
14382 } ) ;
144-
14583} ) ;
14684
14785describe ( 'DeltaSnapshot' , ( ) => {
0 commit comments