From 0710166ce9397f402b835fae745923d11357d15e Mon Sep 17 00:00:00 2001 From: Ali Ok Date: Thu, 28 May 2020 15:49:59 +0300 Subject: [PATCH] fix: initialize CloudEvent's extensions property (#192) Signed-off-by: Ali Ok --- lib/cloudevent.js | 1 + test/cloud_event_test.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/cloudevent.js b/lib/cloudevent.js index 4271ec1..3788508 100644 --- a/lib/cloudevent.js +++ b/lib/cloudevent.js @@ -92,6 +92,7 @@ class CloudEvent { this.time = time; } this.formatter = new Formatter(); + this.extensions = []; } /** diff --git a/test/cloud_event_test.js b/test/cloud_event_test.js index c23d352..89a6279 100644 --- a/test/cloud_event_test.js +++ b/test/cloud_event_test.js @@ -86,6 +86,11 @@ describe("A 1.0 CloudEvent", () => { expect(ce.data).to.equal(data); }); + it("has extensions as an empty array by default", () => { + const ce = new CloudEvent(fixture); + expect(ce.extensions).to.be.an('array').that.has.a.lengthOf(0); + }); + it("throws ValidationError if the CloudEvent does not conform to the schema"); it("returns a JSON string even if format is invalid"); it("correctly formats a CloudEvent as JSON");