From 71f2c5bbb66d0d4d82d6ec498fa78b1ed8bc7bc6 Mon Sep 17 00:00:00 2001 From: Ali Ok Date: Thu, 28 May 2020 10:51:07 +0300 Subject: [PATCH] lib: initialize CloudEvent's extensions property 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 4271ec16..3788508f 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 c23d3525..89a62794 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");