add token tests

This commit is contained in:
Michael C
2022-09-25 02:04:30 -04:00
parent c0952c15c8
commit 9ca087206e
6 changed files with 248 additions and 36 deletions

View File

@@ -8,27 +8,12 @@ let mock: MockAdapter;
import * as patreon from "../mocks/patreonMock";
const validateToken = validatelicenseKeyRegex;
const fakePatreonIdentity = {
data: {},
links: {},
included: [
{
attributes: {
is_monthly: true,
currently_entitled_amount_cents: 100,
patron_status: "active_patron",
},
id: "id",
type: "campaign"
}
],
};
describe("tokenUtils test", function() {
before(function() {
mock = new MockAdapter(axios, { onNoMatch: "throwException" });
mock.onPost("https://www.patreon.com/api/oauth2/token").reply(200, patreon.fakeOauth);
mock.onGet(/identity/).reply(200, patreon.fakeIdentity);
mock.onGet(/identity/).reply(200, patreon.activeIdentity);
});
it("Should be able to create patreon token", function (done) {
@@ -47,7 +32,7 @@ describe("tokenUtils test", function() {
it("Should be able to get patreon identity", function (done) {
if (!config?.patreon) this.skip();
tokenUtils.getPatreonIdentity("fake_access_token").then((result) => {
assert.deepEqual(result, patreon.fakeIdentity);
assert.deepEqual(result, patreon.activeIdentity);
done();
});
});