Remove the responsability of spec checking

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2019-06-21 10:56:41 -03:00
parent 3f13000e35
commit 62e5404c0f
1 changed files with 14 additions and 20 deletions

View File

@ -66,25 +66,6 @@ describe("JSON Event Format Parser", () => {
.to.throw("invalid json payload");
});
it("Throw error when payload is an invalid CloudEvent spec 0.2", () => {
// setup
var payload =
new Cloudevent()
.type(type)
.source(source)
.contenttype(ceContentType)
.time(now)
.schemaurl(schemaurl)
.data(data)
.toString();
var parser = new Parser();
// act and assert
expect(parser.parse.bind(parser, payload))
.to.throw("invalid payload");
});
it("Must accept the CloudEvent spec 0.2 as JSON", () => {
// setup
var payload =
@ -97,7 +78,20 @@ describe("JSON Event Format Parser", () => {
.data(data)
.toString();
var parser = new Parser(new Cloudevent.specs["0.2"]());
var parser = new Parser();
// act
var actual = parser.parse(payload);
// assert
expect(actual)
.to.be.an("object");
});
it("Must accept when the payload is a string well formed as JSON", () => {
// setup
var payload = "{\"much\" : \"wow\"}";
var parser = new Parser();
// act
var actual = parser.parse(payload);