Skip to content

Commit 3f50e71

Browse files
committed
Test the extensions
Signed-off-by: Fabio José <[email protected]>
1 parent f850c9a commit 3f50e71

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

test/bindings/http/receiver_strutured_0_2_test.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,17 @@ describe("HTTP Transport Binding Structured Receiver for CloudEvents v0.2", () =
117117

118118
it("Should accept event that follow the spec 0.2", () => {
119119
// setup
120+
var id = "id-x0dk";
120121
var payload =
121122
new Cloudevent(Cloudevent.specs["0.2"])
122123
.type(type)
123124
.source(source)
125+
.id(id)
124126
.contenttype(ceContentType)
125127
.time(now)
126128
.schemaurl(schemaurl)
127129
.data(data)
128130
.toString();
129-
130131
var headers = {
131132
"content-type":"application/cloudevents+json"
132133
};
@@ -137,6 +138,39 @@ describe("HTTP Transport Binding Structured Receiver for CloudEvents v0.2", () =
137138
// assert
138139
expect(actual)
139140
.to.be.an("object");
141+
142+
expect(actual)
143+
.to.have.property("format");
144+
145+
expect(actual.getId())
146+
.to.equals(id);
147+
});
148+
149+
it("Should accept 'extension1'", () => {
150+
// setup
151+
var extension1 = "mycuston-ext1"
152+
var payload =
153+
new Cloudevent(Cloudevent.specs["0.2"])
154+
.type(type)
155+
.source(source)
156+
.contenttype(ceContentType)
157+
.time(now)
158+
.schemaurl(schemaurl)
159+
.data(data)
160+
.addExtension("extension1", extension1)
161+
.toString();
162+
163+
var headers = {
164+
"content-type":"application/cloudevents+json"
165+
};
166+
167+
// act
168+
var actual = receiver.parse(payload, headers);
169+
var actualExtensions = actual.getExtensions();
170+
171+
// assert
172+
expect(actualExtensions["extension1"])
173+
.to.equal(extension1);
140174
});
141175
});
142176
});

0 commit comments

Comments
 (0)