|
1 |
| -var expect = require("chai").expect; |
| 1 | +const expect = require("chai").expect; |
| 2 | +const {asBase64} = require("../../../lib/utils/fun.js"); |
2 | 3 |
|
3 |
| -var HTTPBinaryReceiver = |
| 4 | +const HTTPBinaryReceiver = |
4 | 5 | require("../../../lib/bindings/http/receiver_binary_1.js");
|
5 | 6 |
|
6 |
| -var receiver = new HTTPBinaryReceiver(); |
| 7 | +const receiver = new HTTPBinaryReceiver(); |
7 | 8 |
|
8 | 9 | describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
9 | 10 | describe("Check", () => {
|
@@ -262,7 +263,7 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
262 | 263 | .to.equal("2019-06-16T11:42:00.000Z");
|
263 | 264 | });
|
264 | 265 |
|
265 |
| - it("Cloudevent contains 'schemaurl'", () => { |
| 266 | + it("Cloudevent contains 'dataschema'", () => { |
266 | 267 | // setup
|
267 | 268 | var payload = {
|
268 | 269 | "data" : "dataString"
|
@@ -373,6 +374,33 @@ describe("HTTP Transport Binding Binary Receiver for CloudEvents v1.0", () => {
|
373 | 374 | .to.deep.equal(payload);
|
374 | 375 | });
|
375 | 376 |
|
| 377 | + it("The content of 'data' is base64 for binary", () => { |
| 378 | + // setup |
| 379 | + var expected = { |
| 380 | + "data" : "dataString" |
| 381 | + }; |
| 382 | + |
| 383 | + let bindata = Uint32Array.from(JSON.stringify(expected), (c) => c.codePointAt(0)); |
| 384 | + let payload = asBase64(bindata); |
| 385 | + |
| 386 | + var attributes = { |
| 387 | + "ce-type" : "type", |
| 388 | + "ce-specversion" : "1.0", |
| 389 | + "ce-source" : "/source", |
| 390 | + "ce-id" : "id", |
| 391 | + "ce-time" : "2019-06-16T11:42:00Z", |
| 392 | + "ce-dataschema" : "http://schema.registry/v1", |
| 393 | + "Content-Type" : "application/json" |
| 394 | + }; |
| 395 | + |
| 396 | + // act |
| 397 | + var actual = receiver.parse(payload, attributes); |
| 398 | + |
| 399 | + // assert |
| 400 | + expect(actual.getData()) |
| 401 | + .to.deep.equal(expected); |
| 402 | + }); |
| 403 | + |
376 | 404 | it("No error when all attributes are in place", () => {
|
377 | 405 | // setup
|
378 | 406 | var payload = {
|
|
0 commit comments