From ac82507f4719806b8cf6ddedebd6d2f1a2da2624 Mon Sep 17 00:00:00 2001 From: "Kai A. Hiller" <V02460@gmail.com> Date: Wed, 26 Jun 2019 07:40:03 -0400 Subject: [PATCH] Undo inclusion of chai-as-promised Signed-off-by: Kai A. Hiller <V02460@gmail.com> --- package.json | 2 -- test/test_matrixeventprocessor.ts | 27 +++++++++++++++++---------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index f7b0259..60894a2 100644 --- a/package.json +++ b/package.json @@ -34,9 +34,7 @@ }, "homepage": "https://github.com/Half-Shot/matrix-appservice-discord#readme", "dependencies": { - "@types/chai-as-promised": "^7.1.0", "better-sqlite3": "^5.0.1", - "chai-as-promised": "^7.1.1", "command-line-args": "^4.0.1", "command-line-usage": "^4.1.0", "discord-markdown": "^2.0.0", diff --git a/test/test_matrixeventprocessor.ts b/test/test_matrixeventprocessor.ts index 033ce45..149351a 100644 --- a/test/test_matrixeventprocessor.ts +++ b/test/test_matrixeventprocessor.ts @@ -15,7 +15,6 @@ limitations under the License. */ import * as Chai from "chai"; -import * as ChaiAsPromised from "chai-as-promised"; import * as Discord from "discord.js"; import * as Proxyquire from "proxyquire"; import { EventTooOldError, EventUnknownError} from "matrix-appservice-bridge"; @@ -36,7 +35,6 @@ import { IMatrixEvent } from "../src/matrixtypes"; const TEST_TIMESTAMP = 1337; -Chai.use(ChaiAsPromised); const expect = Chai.expect; // const assert = Chai.assert; function buildRequest(eventData) { @@ -816,18 +814,27 @@ This is the reply`, it("should reject old events", async () => { const AGE = 900001; // 15 * 60 * 1000 + 1 const processor = createMatrixEventProcessor(); - const callbackPromise = processor.OnEvent(buildRequest({unsigned: {age: AGE}}), null); - expect(callbackPromise).to.eventually.be.rejectedWith(EventTooOldError); + let err; + try { + await processor.OnEvent(buildRequest({unsigned: {age: AGE}}), null); + } catch (e) { err = e; } + expect(err).to.be.an.instanceof(EventTooOldError); }); it("should reject un-processable events", async () => { const AGE = 900000; // 15 * 60 * 1000 const processor = createMatrixEventProcessor(); - // check if nothing is thrown - const callbackPromise = processor.OnEvent(buildRequest({ - content: {}, - type: "m.potato", - unsigned: {age: AGE}}), null); - expect(callbackPromise).to.eventually.be.rejectedWith(EventUnknownError); + let err; + try { + await processor.OnEvent( + buildRequest({ + content: {}, + type: "m.potato", + unsigned: {age: AGE}, + }), + null, + ); + } catch (e) { err = e; } + expect(err).to.be.an.instanceof(EventUnknownError); }); it("should handle own invites", async () => { const processor = createMatrixEventProcessor(); -- GitLab