From acae9da06c81f95dd1f577119749eb3d5f7facb0 Mon Sep 17 00:00:00 2001 From: Michael C Date: Sun, 12 Mar 2023 16:30:08 -0400 Subject: [PATCH] increase coverage for tokenUtils --- test/cases/tokenUtils.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/cases/tokenUtils.ts b/test/cases/tokenUtils.ts index 742bf48..8ff9076 100644 --- a/test/cases/tokenUtils.ts +++ b/test/cases/tokenUtils.ts @@ -44,6 +44,31 @@ describe("tokenUtils test", function() { }); }); + after(function () { + mock.restore(); + }); +}); + +describe("tokenUtils failing tests", function() { + before(function() { + mock = new MockAdapter(axios, { onNoMatch: "throwException" }); + mock.onPost("https://www.patreon.com/api/oauth2/token").reply(204, patreon.fakeOauth); + mock.onGet(/identity/).reply(204, patreon.activeIdentity); + }); + + it("Should fail if patreon is not correctly stubbed", function (done) { + tokenUtils.createAndSaveToken(tokenUtils.TokenType.patreon, "test_code").then((licenseKey) => { + assert.strictEqual(licenseKey, null); + done(); + }); + }); + it("Should fail if token type is invalid", (done) => { + tokenUtils.createAndSaveToken("invalidTokenType" as tokenUtils.TokenType).then((licenseKey) => { + assert.strictEqual(licenseKey, null); + done(); + }); + }); + after(function () { mock.restore(); });