Skip to content

Commit 62e5404

Browse files
committed
Remove the responsability of spec checking
Signed-off-by: Fabio José <[email protected]>
1 parent 3f13000 commit 62e5404

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

test/formats/json/parser_test.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ describe("JSON Event Format Parser", () => {
6666
.to.throw("invalid json payload");
6767
});
6868

69-
it("Throw error when payload is an invalid CloudEvent spec 0.2", () => {
69+
it("Must accept the CloudEvent spec 0.2 as JSON", () => {
7070
// setup
7171
var payload =
72-
new Cloudevent()
72+
new Cloudevent(Cloudevent.specs["0.2"])
7373
.type(type)
7474
.source(source)
7575
.contenttype(ceContentType)
@@ -80,24 +80,18 @@ describe("JSON Event Format Parser", () => {
8080

8181
var parser = new Parser();
8282

83-
// act and assert
84-
expect(parser.parse.bind(parser, payload))
85-
.to.throw("invalid payload");
83+
// act
84+
var actual = parser.parse(payload);
85+
86+
// assert
87+
expect(actual)
88+
.to.be.an("object");
8689
});
8790

88-
it("Must accept the CloudEvent spec 0.2 as JSON", () => {
91+
it("Must accept when the payload is a string well formed as JSON", () => {
8992
// setup
90-
var payload =
91-
new Cloudevent(Cloudevent.specs["0.2"])
92-
.type(type)
93-
.source(source)
94-
.contenttype(ceContentType)
95-
.time(now)
96-
.schemaurl(schemaurl)
97-
.data(data)
98-
.toString();
99-
100-
var parser = new Parser(new Cloudevent.specs["0.2"]());
93+
var payload = "{\"much\" : \"wow\"}";
94+
var parser = new Parser();
10195

10296
// act
10397
var actual = parser.parse(payload);

0 commit comments

Comments
 (0)