chore: fix promise tests to break the build when they fail (#305)
* squash: return the promise that is being tested fixes #303 Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
This commit is contained in:
parent
ad0c4340b2
commit
a5249de487
|
@ -51,7 +51,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
|
|||
[ext3Name]: ext3Value,
|
||||
});
|
||||
|
||||
it("Sends a binary 1.0 CloudEvent by default", () => {
|
||||
it("Sends a binary 1.0 CloudEvent by default", () =>
|
||||
emitter
|
||||
.send(event)
|
||||
.then((response: AxiosResponse) => {
|
||||
|
@ -66,8 +66,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
|
|||
expect(response.data[`${CONSTANTS.EXTENSIONS_PREFIX}${ext2Name}`]).to.equal(ext2Value);
|
||||
expect(response.data[`${CONSTANTS.EXTENSIONS_PREFIX}${ext3Name}`].value).to.equal(ext3Value.value);
|
||||
})
|
||||
.catch(expect.fail);
|
||||
});
|
||||
.catch(expect.fail));
|
||||
|
||||
it("Provides the HTTP headers for a binary event", () => {
|
||||
const headers = headersFor(event);
|
||||
|
@ -78,7 +77,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
|
|||
expect(headers[CONSTANTS.CE_HEADERS.TIME]).to.equal(event.time);
|
||||
});
|
||||
|
||||
it("Sends a binary CloudEvent with Custom Headers", () => {
|
||||
it("Sends a binary CloudEvent with Custom Headers", () =>
|
||||
emitter
|
||||
.send(event, { headers: { customheader: "value" } })
|
||||
.then((response: { data: { [k: string]: string } }) => {
|
||||
|
@ -90,10 +89,9 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
|
|||
// A binary message will have a request body for the data
|
||||
expect(response.data.lunchBreak).to.equal(data.lunchBreak);
|
||||
})
|
||||
.catch(expect.fail);
|
||||
});
|
||||
.catch(expect.fail));
|
||||
|
||||
it("Sends a structured 1.0 CloudEvent if specified", () => {
|
||||
it("Sends a structured 1.0 CloudEvent if specified", () =>
|
||||
emitter
|
||||
.send(event, { protocol: Protocol.HTTPStructured })
|
||||
.then((response: { data: { [k: string]: string | Record<string, string>; data: { lunchBreak: string } } }) => {
|
||||
|
@ -108,8 +106,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
|
|||
expect(response.data[ext1Name]).to.equal(ext1Value);
|
||||
expect(response.data[ext2Name]).to.equal(ext2Value);
|
||||
})
|
||||
.catch(expect.fail);
|
||||
});
|
||||
.catch(expect.fail));
|
||||
|
||||
it("Sends to an alternate URL if specified", () => {
|
||||
nock(receiver)
|
||||
|
@ -124,7 +121,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
|
|||
return [201, returnBody];
|
||||
});
|
||||
|
||||
emitter
|
||||
return emitter
|
||||
.send(event, { protocol: Protocol.HTTPStructured, url: `${receiver}alternate` })
|
||||
.then((response: AxiosResponse) => {
|
||||
// A structured message will have a cloud event content type
|
||||
|
@ -152,7 +149,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
|
|||
[ext3Name]: ext3Value,
|
||||
});
|
||||
|
||||
it("Sends a binary 0.3 CloudEvent", () => {
|
||||
it("Sends a binary 0.3 CloudEvent", () =>
|
||||
emitter
|
||||
.send(event)
|
||||
.then((response: AxiosResponse) => {
|
||||
|
@ -166,8 +163,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
|
|||
expect(response.data[`${CONSTANTS.EXTENSIONS_PREFIX}${ext2Name}`]).to.equal(ext2Value);
|
||||
expect(response.data[`${CONSTANTS.EXTENSIONS_PREFIX}${ext3Name}`].value).to.equal(ext3Value.value);
|
||||
})
|
||||
.catch(expect.fail);
|
||||
});
|
||||
.catch(expect.fail));
|
||||
|
||||
it("Provides the HTTP headers for a binary event", () => {
|
||||
const headers = headersFor(event);
|
||||
|
@ -178,7 +174,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
|
|||
expect(headers[CONSTANTS.CE_HEADERS.TIME]).to.equal(event.time);
|
||||
});
|
||||
|
||||
it("Sends a structured 0.3 CloudEvent if specified", () => {
|
||||
it("Sends a structured 0.3 CloudEvent if specified", () =>
|
||||
emitter
|
||||
.send(event, { protocol: Protocol.HTTPStructured })
|
||||
.then(
|
||||
|
@ -197,8 +193,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
|
|||
expect(response.data[ext2Name]).to.equal(ext2Value);
|
||||
},
|
||||
)
|
||||
.catch(expect.fail);
|
||||
});
|
||||
.catch(expect.fail));
|
||||
|
||||
it("Sends to an alternate URL if specified", () => {
|
||||
nock(receiver)
|
||||
|
@ -213,7 +208,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
|
|||
return [201, returnBody];
|
||||
});
|
||||
|
||||
emitter
|
||||
return emitter
|
||||
.send(event, { protocol: Protocol.HTTPStructured, url: `${receiver}alternate` })
|
||||
.then(
|
||||
(response: {
|
||||
|
|
Loading…
Reference in New Issue