Tests for structured http emitter v0.3
Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
parent
35949719fb
commit
62015c0d0a
|
@ -58,6 +58,7 @@ const httpcfg = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const binary = new BinaryHTTPEmitter(httpcfg);
|
const binary = new BinaryHTTPEmitter(httpcfg);
|
||||||
|
const structured = new v03.StructuredHTTPEmitter(httpcfg);
|
||||||
|
|
||||||
describe("HTTP Transport Binding - Version 0.3", () => {
|
describe("HTTP Transport Binding - Version 0.3", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@ -67,6 +68,36 @@ describe("HTTP Transport Binding - Version 0.3", () => {
|
||||||
.reply(201, {status: "accepted"});
|
.reply(201, {status: "accepted"});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Structured", () => {
|
||||||
|
describe("JSON Format", () => {
|
||||||
|
it("requires '" + contentType + "' Content-Type in the header", () => {
|
||||||
|
return structured.emit(cloudevent)
|
||||||
|
.then((response) => {
|
||||||
|
expect(response.config.headers["Content-Type"])
|
||||||
|
.to.equal(contentType);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("the request payload should be correct", () => {
|
||||||
|
return structured.emit(cloudevent)
|
||||||
|
.then((response) => {
|
||||||
|
expect(JSON.parse(response.config.data))
|
||||||
|
.to.deep.equal(cloudevent.format());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("'data' attribute with 'base64' encoding", () => {
|
||||||
|
it("the request payload should be correct", () => {
|
||||||
|
return structured.emit(cebase64)
|
||||||
|
.then((response) => {
|
||||||
|
expect(JSON.parse(response.config.data).data)
|
||||||
|
.to.equal(cebase64.format().data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("Binary", () => {
|
describe("Binary", () => {
|
||||||
describe("JSON Format", () => {
|
describe("JSON Format", () => {
|
||||||
it("requires '" + cloudevent.getDataContentType() + "' Content-Type in the header", () => {
|
it("requires '" + cloudevent.getDataContentType() + "' Content-Type in the header", () => {
|
||||||
|
@ -133,14 +164,6 @@ describe("HTTP Transport Binding - Version 0.3", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("HTTP Header contains 'ce-datacontentencoding'", () => {
|
|
||||||
return binary.emit(cebase64)
|
|
||||||
.then((response) => {
|
|
||||||
expect(response.config.headers)
|
|
||||||
.to.have.property("ce-datacontentencoding");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("HTTP Header contains 'ce-" + ext1Name + "'", () => {
|
it("HTTP Header contains 'ce-" + ext1Name + "'", () => {
|
||||||
return binary.emit(cloudevent)
|
return binary.emit(cloudevent)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
@ -164,6 +187,16 @@ describe("HTTP Transport Binding - Version 0.3", () => {
|
||||||
.to.have.property("ce-subject");
|
.to.have.property("ce-subject");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("'data' attribute with 'base64' encoding", () => {
|
||||||
|
it("HTTP Header contains 'ce-datacontentencoding'", () => {
|
||||||
|
return binary.emit(cebase64)
|
||||||
|
.then((response) => {
|
||||||
|
expect(response.config.headers)
|
||||||
|
.to.have.property("ce-datacontentencoding");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue