From 447d686e3682fe34efaa61629da5f92a0ed9eb53 Mon Sep 17 00:00:00 2001 From: Helio Frota <00hf11@gmail.com> Date: Wed, 29 Apr 2020 18:57:41 -0300 Subject: [PATCH] fix: Unhandled promise rejection in tests Signed-off-by: Helio Frota <00hf11@gmail.com> --- test/bindings/http/unmarshaller_0_3_tests.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/bindings/http/unmarshaller_0_3_tests.js b/test/bindings/http/unmarshaller_0_3_tests.js index 6bc3deb6..ba26586f 100644 --- a/test/bindings/http/unmarshaller_0_3_tests.js +++ b/test/bindings/http/unmarshaller_0_3_tests.js @@ -89,7 +89,7 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => { expect(err.message).to.equal("structured+type not allowed")); }); - it("Throw error when the event does not follow the spec 0.3", () => { + it("Throw error when the event does not follow the spec 0.3", async() => { // setup const payload = new v03.CloudEvent(v03.Spec) @@ -108,10 +108,13 @@ describe("HTTP Transport Binding Unmarshaller for CloudEvents v0.3", () => { const un = new Unmarshaller(); // act and assert - un.unmarshall(payload, headers) - .then(() => { throw new Error("failed"); }) - .catch((err) => - expect(err.message).to.equal("invalid payload")); + try { + await un.unmarshall(payload, headers); + const spec = new v03.Spec(); + spec.check(payload); + } catch (err) { + expect(err.message).to.equal("invalid payload"); + } }); it("Should accept event that follow the spec 0.3", () => {