More test cases
Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
parent
30796b2147
commit
3dd2993e5a
|
@ -9,7 +9,7 @@ const contenttype = "application/json";
|
||||||
const data = {};
|
const data = {};
|
||||||
const extensions = {};
|
const extensions = {};
|
||||||
|
|
||||||
var cloudevent =
|
var cloudevent =
|
||||||
new Cloudevent(Cloudevent.specs["0.2"])
|
new Cloudevent(Cloudevent.specs["0.2"])
|
||||||
.type(type)
|
.type(type)
|
||||||
.source(source);
|
.source(source);
|
||||||
|
@ -27,6 +27,14 @@ describe("CloudEvents Spec 0.2 - JavaScript SDK", () => {
|
||||||
expect(cloudevent.format()).to.have.property("specversion");
|
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'", () => {
|
it("requires 'source'", () => {
|
||||||
expect(cloudevent.format()).to.have.property("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");
|
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'", () => {
|
it("contains 'contenttype'", () => {
|
||||||
cloudevent.contenttype(contenttype);
|
cloudevent.contenttype(contenttype);
|
||||||
expect(cloudevent.format()).to.have.property("contenttype");
|
expect(cloudevent.format()).to.have.property("contenttype");
|
||||||
|
@ -68,8 +84,8 @@ describe("CloudEvents Spec 0.2 - JavaScript SDK", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should throw an error when employ reserved name as extension", () => {
|
it("should throw an error when employ reserved name as extension", () => {
|
||||||
|
|
||||||
var cevt =
|
var cevt =
|
||||||
new Cloudevent(Cloudevent.specs["0.2"])
|
new Cloudevent(Cloudevent.specs["0.2"])
|
||||||
.type(type)
|
.type(type)
|
||||||
.source(source);
|
.source(source);
|
||||||
|
|
Loading…
Reference in New Issue