Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix promise tests to break the build when they fail #305

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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