mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-15 16:07:03 +03:00
move patreon mock
This commit is contained in:
@@ -5,6 +5,7 @@ import * as tokenUtils from "../../src/utils/tokenUtils";
|
||||
import MockAdapter from "axios-mock-adapter";
|
||||
import { validatelicenseKeyRegex } from "../../src/routes/verifyToken";
|
||||
let mock: MockAdapter;
|
||||
import * as patreon from "../mocks/patreonMock";
|
||||
|
||||
const validateToken = validatelicenseKeyRegex;
|
||||
const fakePatreonIdentity = {
|
||||
@@ -26,12 +27,8 @@ const fakePatreonIdentity = {
|
||||
describe("tokenUtils test", function() {
|
||||
before(function() {
|
||||
mock = new MockAdapter(axios, { onNoMatch: "throwException" });
|
||||
mock.onPost("https://www.patreon.com/api/oauth2/token").reply(200, {
|
||||
access_token: "test_access_token",
|
||||
refresh_token: "test_refresh_token",
|
||||
expires_in: 3600,
|
||||
});
|
||||
mock.onGet(/identity/).reply(200, fakePatreonIdentity);
|
||||
mock.onPost("https://www.patreon.com/api/oauth2/token").reply(200, patreon.fakeOauth);
|
||||
mock.onGet(/identity/).reply(200, patreon.fakeIdentity);
|
||||
});
|
||||
|
||||
it("Should be able to create patreon token", function (done) {
|
||||
@@ -50,7 +47,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, fakePatreonIdentity);
|
||||
assert.deepEqual(result, patreon.fakeIdentity);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user