Skip to content

Commit a5249de

Browse files
authored
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 <[email protected]>
1 parent ad0c434 commit a5249de

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

test/integration/http_emitter_test.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
5151
[ext3Name]: ext3Value,
5252
});
5353

54-
it("Sends a binary 1.0 CloudEvent by default", () => {
54+
it("Sends a binary 1.0 CloudEvent by default", () =>
5555
emitter
5656
.send(event)
5757
.then((response: AxiosResponse) => {
@@ -66,8 +66,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
6666
expect(response.data[`${CONSTANTS.EXTENSIONS_PREFIX}${ext2Name}`]).to.equal(ext2Value);
6767
expect(response.data[`${CONSTANTS.EXTENSIONS_PREFIX}${ext3Name}`].value).to.equal(ext3Value.value);
6868
})
69-
.catch(expect.fail);
70-
});
69+
.catch(expect.fail));
7170

7271
it("Provides the HTTP headers for a binary event", () => {
7372
const headers = headersFor(event);
@@ -78,7 +77,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
7877
expect(headers[CONSTANTS.CE_HEADERS.TIME]).to.equal(event.time);
7978
});
8079

81-
it("Sends a binary CloudEvent with Custom Headers", () => {
80+
it("Sends a binary CloudEvent with Custom Headers", () =>
8281
emitter
8382
.send(event, { headers: { customheader: "value" } })
8483
.then((response: { data: { [k: string]: string } }) => {
@@ -90,10 +89,9 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
9089
// A binary message will have a request body for the data
9190
expect(response.data.lunchBreak).to.equal(data.lunchBreak);
9291
})
93-
.catch(expect.fail);
94-
});
92+
.catch(expect.fail));
9593

96-
it("Sends a structured 1.0 CloudEvent if specified", () => {
94+
it("Sends a structured 1.0 CloudEvent if specified", () =>
9795
emitter
9896
.send(event, { protocol: Protocol.HTTPStructured })
9997
.then((response: { data: { [k: string]: string | Record<string, string>; data: { lunchBreak: string } } }) => {
@@ -108,8 +106,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
108106
expect(response.data[ext1Name]).to.equal(ext1Value);
109107
expect(response.data[ext2Name]).to.equal(ext2Value);
110108
})
111-
.catch(expect.fail);
112-
});
109+
.catch(expect.fail));
113110

114111
it("Sends to an alternate URL if specified", () => {
115112
nock(receiver)
@@ -124,7 +121,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
124121
return [201, returnBody];
125122
});
126123

127-
emitter
124+
return emitter
128125
.send(event, { protocol: Protocol.HTTPStructured, url: `${receiver}alternate` })
129126
.then((response: AxiosResponse) => {
130127
// A structured message will have a cloud event content type
@@ -152,7 +149,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
152149
[ext3Name]: ext3Value,
153150
});
154151

155-
it("Sends a binary 0.3 CloudEvent", () => {
152+
it("Sends a binary 0.3 CloudEvent", () =>
156153
emitter
157154
.send(event)
158155
.then((response: AxiosResponse) => {
@@ -166,8 +163,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
166163
expect(response.data[`${CONSTANTS.EXTENSIONS_PREFIX}${ext2Name}`]).to.equal(ext2Value);
167164
expect(response.data[`${CONSTANTS.EXTENSIONS_PREFIX}${ext3Name}`].value).to.equal(ext3Value.value);
168165
})
169-
.catch(expect.fail);
170-
});
166+
.catch(expect.fail));
171167

172168
it("Provides the HTTP headers for a binary event", () => {
173169
const headers = headersFor(event);
@@ -178,7 +174,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
178174
expect(headers[CONSTANTS.CE_HEADERS.TIME]).to.equal(event.time);
179175
});
180176

181-
it("Sends a structured 0.3 CloudEvent if specified", () => {
177+
it("Sends a structured 0.3 CloudEvent if specified", () =>
182178
emitter
183179
.send(event, { protocol: Protocol.HTTPStructured })
184180
.then(
@@ -197,8 +193,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
197193
expect(response.data[ext2Name]).to.equal(ext2Value);
198194
},
199195
)
200-
.catch(expect.fail);
201-
});
196+
.catch(expect.fail));
202197

203198
it("Sends to an alternate URL if specified", () => {
204199
nock(receiver)
@@ -213,7 +208,7 @@ describe("HTTP Transport Binding Emitter for CloudEvents", () => {
213208
return [201, returnBody];
214209
});
215210

216-
emitter
211+
return emitter
217212
.send(event, { protocol: Protocol.HTTPStructured, url: `${receiver}alternate` })
218213
.then(
219214
(response: {

0 commit comments

Comments
 (0)