increase coverage for tokenUtils

This commit is contained in:
Michael C 2023-03-12 16:30:08 -04:00
parent 1f939116a4
commit acae9da06c
No known key found for this signature in database
GPG key ID: FFB04FB3B878B7B4

View file

@ -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();
});