Skip to content

Commit

Permalink
chore: fix promise tests to break the build when they fail (#305)
Browse files Browse the repository at this point in the history
* squash: return the promise that is being tested

fixes #303 

Signed-off-by: Lucas Holmquist <lholmqui@redhat.com>
  • Loading branch information
lholmquist authored Aug 7, 2020
1 parent ad0c434 commit a5249de
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions test/integration/http_emitter_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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);
Expand All @@ -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 } }) => {
Expand All @@ -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 } } }) => {
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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) => {
Expand All @@ -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);
Expand All @@ -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(
Expand All @@ -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)
Expand All @@ -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: {
Expand Down

0 comments on commit a5249de

Please sign in to comment.