Skip to content

Commit 0710166

Browse files
authored
fix: initialize CloudEvent's extensions property (cloudevents#192)
Signed-off-by: Ali Ok <aliok@redhat.com>
1 parent daf945c commit 0710166

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/cloudevent.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class CloudEvent {
9292
this.time = time;
9393
}
9494
this.formatter = new Formatter();
95+
this.extensions = [];
9596
}
9697

9798
/**

test/cloud_event_test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ describe("A 1.0 CloudEvent", () => {
8686
expect(ce.data).to.equal(data);
8787
});
8888

89+
it("has extensions as an empty array by default", () => {
90+
const ce = new CloudEvent(fixture);
91+
expect(ce.extensions).to.be.an('array').that.has.a.lengthOf(0);
92+
});
93+
8994
it("throws ValidationError if the CloudEvent does not conform to the schema");
9095
it("returns a JSON string even if format is invalid");
9196
it("correctly formats a CloudEvent as JSON");

0 commit comments

Comments
 (0)