Test for extensions

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2019-07-17 14:49:14 -03:00
parent 6960e42c24
commit 7d67e27d07
1 changed files with 23 additions and 2 deletions

View File

@ -15,17 +15,24 @@ const data = {
foo: "bar"
};
const ext1Name = "extension1";
const ext1Value = "foobar";
const ext2Name = "extension2";
const ext2Value = "acme";
const Structured01 = Cloudevent.bindings["http-structured0.1"];
const Binary01 = Cloudevent.bindings["http-binary0.1"];
var cloudevent =
var cloudevent =
new Cloudevent()
.type(type)
.source(source)
.contenttype(ceContentType)
.time(now)
.schemaurl(schemaurl)
.data(data);
.data(data)
.addExtension(ext1Name, ext1Value)
.addExtension(ext2Name, ext2Value);
cloudevent.eventTypeVersion("1.0.0");
@ -90,6 +97,7 @@ describe("HTTP Transport Binding - Version 0.1", () => {
.to.have.property("CE-EventType");
});
});
it("HTTP Header contains 'CE-EventTypeVersion'", () => {
return httpbinary01.emit(cloudevent)
.then((response) => {
@ -97,6 +105,7 @@ describe("HTTP Transport Binding - Version 0.1", () => {
.to.have.property("CE-EventTypeVersion");
});
});
it("HTTP Header contains 'CE-CloudEventsVersion'", () => {
return httpbinary01.emit(cloudevent)
.then((response) => {
@ -104,6 +113,7 @@ describe("HTTP Transport Binding - Version 0.1", () => {
.to.have.property("CE-CloudEventsVersion");
});
});
it("HTTP Header contains 'CE-Source'", () => {
return httpbinary01.emit(cloudevent)
.then((response) => {
@ -111,6 +121,7 @@ describe("HTTP Transport Binding - Version 0.1", () => {
.to.have.property("CE-Source");
});
});
it("HTTP Header contains 'CE-EventID'", () => {
return httpbinary01.emit(cloudevent)
.then((response) => {
@ -118,6 +129,7 @@ describe("HTTP Transport Binding - Version 0.1", () => {
.to.have.property("CE-EventID");
});
});
it("HTTP Header contains 'CE-EventTime'", () => {
return httpbinary01.emit(cloudevent)
.then((response) => {
@ -125,6 +137,7 @@ describe("HTTP Transport Binding - Version 0.1", () => {
.to.have.property("CE-EventTime");
});
});
it("HTTP Header contains 'CE-SchemaURL'", () => {
return httpbinary01.emit(cloudevent)
.then((response) => {
@ -132,6 +145,14 @@ describe("HTTP Transport Binding - Version 0.1", () => {
.to.have.property("CE-SchemaURL");
});
});
it("HTTP Header contains 'CE-X-Extension1' as extension", () => {
return httpbinary01.emit(cloudevent)
.then((response) => {
expect(response.config.headers)
.to.have.property("CE-X-Extension1");
});
});
});
});
});