From 62e5404c0f3a9b006050d60e8ac2f820db781e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabio=20Jos=C3=A9?= Date: Fri, 21 Jun 2019 10:56:41 -0300 Subject: [PATCH] Remove the responsability of spec checking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabio José --- test/formats/json/parser_test.js | 34 +++++++++++++------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/test/formats/json/parser_test.js b/test/formats/json/parser_test.js index 41b6e75..2c631d5 100644 --- a/test/formats/json/parser_test.js +++ b/test/formats/json/parser_test.js @@ -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);