Skip to content
Extraits de code Groupes Projets
Valider 225d6239 rédigé par Will Hunt's avatar Will Hunt
Parcourir les fichiers

Replace then/catch with try/catch

parent 31826772
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -15,19 +15,20 @@ describe("Provisioner", () => {
it("should fail to bridge a room that timed out", async () => {
const p = new Provisioner();
const startAt = Date.now();
try {
await p.AskBridgePermission(
new MockChannel("foo", "bar") as any,
"Mark",
TIMEOUT_MS,
).then(() => {
)
throw Error("Should have thrown an error");
}).catch((err) => {
} catch (err) {
expect(err.message).to.eq("Timed out waiting for a response from the Discord owners");
const delay = Date.now() - startAt;
if (delay < TIMEOUT_MS) {
throw Error(`Should have waited for timeout before resolving, waited: ${delay}ms`);
}
});
}
});
it("should fail to bridge a room that was declined", async () => {
const p = new Provisioner();
......@@ -35,13 +36,15 @@ describe("Provisioner", () => {
new MockChannel("foo", "bar") as any,
"Mark",
TIMEOUT_MS,
).then(() => {
throw Error("Should have thrown an error");
}).catch((err) => {
expect(err.message).to.eq("The bridge has been declined by the Discord guild");
});
);
await p.MarkApproved(new MockChannel("foo", "bar") as any, new MockMember("abc", "Mark") as any, false);
try {
await promise;
throw Error("Should have thrown an error");
} catch (err) {
expect(err.message).to.eq("The bridge has been declined by the Discord guild");
}
});
it("should bridge a room that was approved", async () => {
const p = new Provisioner();
......@@ -49,11 +52,9 @@ describe("Provisioner", () => {
new MockChannel("foo", "bar") as any,
"Mark",
TIMEOUT_MS,
).then((msg) => {
expect(msg).to.eq("Approved");
});
);
await p.MarkApproved(new MockChannel("foo", "bar") as any, new MockMember("abc", "Mark") as any, true);
await promise;
expect(await promise).to.eq("Approved");
});
});
});
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter