@@ -156,38 +156,47 @@ describe('CloudEvents request to event function', () => {
156156 headers : { [ key : string ] : string } ;
157157 body : { } ;
158158 }
159+
160+ const specversion = '1.0' ;
161+ const type = 'com.google.cloud.storage' ;
162+ const source =
163+ 'https://github.com/GoogleCloudPlatform/functions-framework-nodejs' ;
164+ const subject = 'test-subject' ;
165+ const id = 'test-1234-1234' ;
166+ const time = '2020-05-13T01:23:45Z' ;
167+ const datacontenttype = 'application/json' ;
168+ const data = {
169+ some : 'payload' ,
170+ } ;
171+
159172 const testData : TestData [ ] = [
160173 {
161- name : 'CloudEvents v0.2 structured content mode' ,
174+ name : 'CloudEvents v1.0 structured content mode' ,
162175 headers : { 'Content-Type' : 'application/cloudevents+json' } ,
163176 body : {
164- type : 'testType' ,
165- specversion : 'testSpecversion' ,
166- source : 'testSource' ,
167- id : 'testId' ,
168- time : 'testTime' ,
169- schemaurl : 'testSchemaurl' ,
170- contenttype : 'testContenttype' ,
171- data : {
172- some : 'payload' ,
173- } ,
177+ specversion,
178+ type,
179+ source,
180+ subject,
181+ id,
182+ time,
183+ datacontenttype,
184+ data,
174185 } ,
175186 } ,
176187 {
177- name : 'CloudEvents v0.2 binary content mode' ,
188+ name : 'CloudEvents v1.0 binary content mode' ,
178189 headers : {
179190 'Content-Type' : 'application/json' ,
180- 'ce-type' : 'testType' ,
181- 'ce-specversion' : 'testSpecversion' ,
182- 'ce-source' : 'testSource' ,
183- 'ce-id' : 'testId' ,
184- 'ce-time' : 'testTime' ,
185- 'ce-schemaurl' : 'testSchemaurl' ,
186- 'ce-contenttype' : 'testContenttype' ,
187- } ,
188- body : {
189- some : 'payload' ,
191+ 'ce-specversion' : specversion ,
192+ 'ce-type' : type ,
193+ 'ce-source' : source ,
194+ 'ce-subject' : subject ,
195+ 'ce-id' : id ,
196+ 'ce-time' : time ,
197+ 'ce-datacontenttype' : datacontenttype ,
190198 } ,
199+ body : data ,
191200 } ,
192201 ] ;
193202 testData . forEach ( test => {
@@ -206,15 +215,15 @@ describe('CloudEvents request to event function', () => {
206215 . set ( test . headers )
207216 . send ( test . body )
208217 . expect ( 204 ) ;
209- assert . deepStrictEqual ( receivedData , { some : 'payload' } ) ;
218+ assert . deepStrictEqual ( receivedData , data ) ;
210219 assert . notStrictEqual ( receivedContext , null ) ;
211- assert . strictEqual ( receivedContext ! . type , 'testType' ) ;
212- assert . strictEqual ( receivedContext ! . specversion , 'testSpecversion' ) ;
213- assert . strictEqual ( receivedContext ! . source , 'testSource' ) ;
214- assert . strictEqual ( receivedContext ! . id , 'testId' ) ;
215- assert . strictEqual ( receivedContext ! . time , 'testTime' ) ;
216- assert . strictEqual ( receivedContext ! . schemaurl , 'testSchemaurl' ) ;
217- assert . strictEqual ( receivedContext ! . contenttype , 'testContenttype' ) ;
220+ assert . strictEqual ( receivedContext ! . specversion , specversion ) ;
221+ assert . strictEqual ( receivedContext ! . type , type ) ;
222+ assert . strictEqual ( receivedContext ! . source , source ) ;
223+ assert . strictEqual ( receivedContext ! . subject , subject ) ;
224+ assert . strictEqual ( receivedContext ! . id , id ) ;
225+ assert . strictEqual ( receivedContext ! . time , time ) ;
226+ assert . strictEqual ( receivedContext ! . datacontenttype , datacontenttype ) ;
218227 } ) ;
219228 } ) ;
220229} ) ;
0 commit comments