11const expect = require ( "chai" ) . expect ;
22
3- const HTTPBinaryReceiver =
4- require ( "../../../lib/bindings/http/receiver_binary_0_3 .js" ) ;
3+ const HTTPBinaryReceiver = require ( "../../../lib/bindings/http/receiver_binary_0_3.js" ) ;
4+ const ValidationError = require ( "../../../lib/validation_error .js" ) ;
55const {
66 BINARY_HEADERS_03 ,
77 SPEC_V03 ,
@@ -19,7 +19,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
1919
2020 // act and assert
2121 expect ( receiver . check . bind ( receiver , payload , attributes ) )
22- . to . throw ( "payload is null or undefined" ) ;
22+ . to . throw ( ValidationError , "payload is null or undefined" ) ;
2323 } ) ;
2424
2525 it ( "Throw error when attributes arg is null or undefined" , ( ) => {
@@ -29,7 +29,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
2929
3030 // act and assert
3131 expect ( receiver . check . bind ( receiver , payload , attributes ) )
32- . to . throw ( "attributes is null or undefined" ) ;
32+ . to . throw ( ValidationError , "attributes is null or undefined" ) ;
3333 } ) ;
3434
3535 it ( "Throw error when payload is not an object or string" , ( ) => {
@@ -39,7 +39,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
3939
4040 // act and assert
4141 expect ( receiver . check . bind ( receiver , payload , attributes ) )
42- . to . throw ( "payload must be an object or a string" ) ;
42+ . to . throw ( ValidationError , "payload must be an object or a string" ) ;
4343 } ) ;
4444
4545 it ( "Throw error when headers has no 'ce-type'" , ( ) => {
@@ -54,7 +54,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
5454
5555 // act and assert
5656 expect ( receiver . check . bind ( receiver , payload , attributes ) )
57- . to . throw ( "header 'ce-type' not found" ) ;
57+ . to . throw ( ValidationError , "header 'ce-type' not found" ) ;
5858 } ) ;
5959
6060 it ( "Throw error when headers has no 'ce-specversion'" , ( ) => {
@@ -69,7 +69,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
6969
7070 // act and assert
7171 expect ( receiver . check . bind ( receiver , payload , attributes ) )
72- . to . throw ( "header 'ce-specversion' not found" ) ;
72+ . to . throw ( ValidationError , "header 'ce-specversion' not found" ) ;
7373 } ) ;
7474
7575 it ( "Throw error when headers has no 'ce-source'" , ( ) => {
@@ -84,7 +84,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
8484
8585 // act and assert
8686 expect ( receiver . check . bind ( receiver , payload , attributes ) )
87- . to . throw ( "header 'ce-source' not found" ) ;
87+ . to . throw ( ValidationError , "header 'ce-source' not found" ) ;
8888 } ) ;
8989
9090 it ( "Throw error when headers has no 'ce-id'" , ( ) => {
@@ -99,7 +99,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
9999
100100 // act and assert
101101 expect ( receiver . check . bind ( receiver , payload , attributes ) )
102- . to . throw ( "header 'ce-id' not found" ) ;
102+ . to . throw ( ValidationError , "header 'ce-id' not found" ) ;
103103 } ) ;
104104
105105 it ( "Throw error when spec is not 0.3" , ( ) => {
@@ -115,7 +115,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
115115
116116 // act and assert
117117 expect ( receiver . parse . bind ( receiver , payload , attributes ) )
118- . to . throw ( "invalid spec version" ) ;
118+ . to . throw ( ValidationError , "invalid spec version" ) ;
119119 } ) ;
120120
121121 it ( "Throw error when the content-type is invalid" , ( ) => {
@@ -131,7 +131,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v0.3", () => {
131131
132132 // act and assert
133133 expect ( receiver . check . bind ( receiver , payload , attributes ) )
134- . to . throw ( "invalid content type" ) ;
134+ . to . throw ( ValidationError , "invalid content type" ) ;
135135 } ) ;
136136
137137 it ( "No error when all required headers are in place" , ( ) => {
0 commit comments