Fix tests

This commit is contained in:
Ajay
2022-10-30 17:07:25 -04:00
parent 2254e7f869
commit 5139c7aaf0
2 changed files with 6 additions and 6 deletions

View File

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

View File

@@ -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() {