@@ -62,86 +62,24 @@ describe('DatabaseBuilder', () => {
62
62
resource : 'projects/_/instances/subdomains/refs/users' ,
63
63
} as any ) ;
64
64
} ) ;
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
- } ) ;
77
65
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' ) ;
81
69
} ) ;
82
70
83
71
return handler ( {
84
72
data : {
85
73
data : null ,
86
- delta : { foo : 'bar' } ,
74
+ delta : 'hello' ,
87
75
} ,
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' ,
113
79
} ,
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' } ) ;
133
80
} ) ;
134
-
135
- return handler ( {
136
- data : {
137
- data : null ,
138
- delta : { foo : 'bar' } ,
139
- } ,
140
- resource : 'projects/_/instances/subdomains/refs/users' ,
141
- } as any ) ;
142
81
} ) ;
143
82
} ) ;
144
-
145
83
} ) ;
146
84
147
85
describe ( 'DeltaSnapshot' , ( ) => {
0 commit comments