fix: initialize CloudEvent's extensions property (#192)

Signed-off-by: Ali Ok <aliok@redhat.com>
This commit is contained in:
Ali Ok 2020-05-28 15:49:59 +03:00 committed by GitHub
parent daf945c50e
commit 0710166ce9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -92,6 +92,7 @@ class CloudEvent {
this.time = time; this.time = time;
} }
this.formatter = new Formatter(); this.formatter = new Formatter();
this.extensions = [];
} }
/** /**

View File

@ -86,6 +86,11 @@ describe("A 1.0 CloudEvent", () => {
expect(ce.data).to.equal(data); 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("throws ValidationError if the CloudEvent does not conform to the schema");
it("returns a JSON string even if format is invalid"); it("returns a JSON string even if format is invalid");
it("correctly formats a CloudEvent as JSON"); it("correctly formats a CloudEvent as JSON");