More test cases

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2019-05-24 09:17:28 -03:00
parent 30796b2147
commit 3dd2993e5a
1 changed files with 19 additions and 3 deletions

View File

@ -27,6 +27,14 @@ describe("CloudEvents Spec 0.2 - JavaScript SDK", () => {
expect(cloudevent.format()).to.have.property("specversion");
});
it("should throw an error when mandatory attribute is absent", () => {
delete cloudevent.spec.payload.source;
expect(cloudevent.format.bind(cloudevent))
.to
.throw("invalid payload");
cloudevent.spec.payload.source = source;
});
it("requires 'source'", () => {
expect(cloudevent.format()).to.have.property("source");
});
@ -47,6 +55,14 @@ describe("CloudEvents Spec 0.2 - JavaScript SDK", () => {
expect(cloudevent.format()).to.have.property("schemaurl");
});
it("should throw an error when 'schemaurl' is not an URI", () => {
cloudevent.spec.payload.schemaurl = "KKKKKK";
expect(cloudevent.format.bind(cloudevent))
.to
.throw("invalid payload");
cloudevent.spec.payload.schemaurl = schemaurl;
});
it("contains 'contenttype'", () => {
cloudevent.contenttype(contenttype);
expect(cloudevent.format()).to.have.property("contenttype");