mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-06 03:26:59 +03:00
Fix tests
This commit is contained in:
@@ -7,7 +7,7 @@ let mock: MockAdapter;
|
|||||||
import * as patreon from "../mocks/patreonMock";
|
import * as patreon from "../mocks/patreonMock";
|
||||||
import * as gumroad from "../mocks/gumroadMock";
|
import * as gumroad from "../mocks/gumroadMock";
|
||||||
import { client } from "../utils/httpClient";
|
import { client } from "../utils/httpClient";
|
||||||
import { validatelicenseKeyRegex } from "../../src/routes/verifyToken";
|
import { validateLicenseKeyRegex } from "../../src/routes/verifyToken";
|
||||||
|
|
||||||
const generateEndpoint = "/api/generateToken";
|
const generateEndpoint = "/api/generateToken";
|
||||||
const getGenerateToken = (type: string, code: string | null, adminUserID: string | null) => client({
|
const getGenerateToken = (type: string, code: string | null, adminUserID: string | null) => client({
|
||||||
@@ -48,7 +48,7 @@ describe("generateToken test", function() {
|
|||||||
if (!config?.patreon) this.skip();
|
if (!config?.patreon) this.skip();
|
||||||
getGenerateToken("patreon", "patreon_code", "").then(res => {
|
getGenerateToken("patreon", "patreon_code", "").then(res => {
|
||||||
patreonLicense = extractLicenseKey(res.data);
|
patreonLicense = extractLicenseKey(res.data);
|
||||||
assert.ok(validatelicenseKeyRegex(patreonLicense));
|
assert.ok(validateLicenseKeyRegex(patreonLicense));
|
||||||
done();
|
done();
|
||||||
}).catch(err => done(err));
|
}).catch(err => done(err));
|
||||||
});
|
});
|
||||||
@@ -58,14 +58,14 @@ describe("generateToken test", function() {
|
|||||||
if (!config?.patreon) this.skip();
|
if (!config?.patreon) this.skip();
|
||||||
getGenerateToken("patreon", "patreon_code", "").then(res => {
|
getGenerateToken("patreon", "patreon_code", "").then(res => {
|
||||||
patreonLicense = extractLicenseKey(res.data);
|
patreonLicense = extractLicenseKey(res.data);
|
||||||
assert.ok(validatelicenseKeyRegex(patreonLicense));
|
assert.ok(validateLicenseKeyRegex(patreonLicense));
|
||||||
done();
|
done();
|
||||||
}).catch(err => done(err));
|
}).catch(err => done(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should be able to create new local token", function (done) {
|
it("Should be able to create new local token", function (done) {
|
||||||
createAndSaveToken(TokenType.local).then((licenseKey) => {
|
createAndSaveToken(TokenType.local).then((licenseKey) => {
|
||||||
assert.ok(validatelicenseKeyRegex(licenseKey));
|
assert.ok(validateLicenseKeyRegex(licenseKey));
|
||||||
localLicense = licenseKey;
|
localLicense = licenseKey;
|
||||||
done();
|
done();
|
||||||
}).catch(err => done(err));
|
}).catch(err => done(err));
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import { config } from "../../src/config";
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import * as tokenUtils from "../../src/utils/tokenUtils";
|
import * as tokenUtils from "../../src/utils/tokenUtils";
|
||||||
import MockAdapter from "axios-mock-adapter";
|
import MockAdapter from "axios-mock-adapter";
|
||||||
import { validatelicenseKeyRegex } from "../../src/routes/verifyToken";
|
import { validateLicenseKeyRegex } from "../../src/routes/verifyToken";
|
||||||
let mock: MockAdapter;
|
let mock: MockAdapter;
|
||||||
import * as patreon from "../mocks/patreonMock";
|
import * as patreon from "../mocks/patreonMock";
|
||||||
|
|
||||||
const validateToken = validatelicenseKeyRegex;
|
const validateToken = validateLicenseKeyRegex;
|
||||||
|
|
||||||
describe("tokenUtils test", function() {
|
describe("tokenUtils test", function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user