mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-16 08:26:59 +03:00
add token tests
This commit is contained in:
22
test/mocks/gumroadMock.ts
Normal file
22
test/mocks/gumroadMock.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export const licenseSuccess = {
|
||||
success: true,
|
||||
uses: 4,
|
||||
purchase: {}
|
||||
};
|
||||
|
||||
export const licenseFail = {
|
||||
success: false,
|
||||
message: "That license does not exist for the provided product."
|
||||
};
|
||||
|
||||
|
||||
const subCode = (length = 8) => {
|
||||
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
let result = "";
|
||||
for (let i = 0; i < length; i++) {
|
||||
result += characters[(Math.floor(Math.random() * characters.length))];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export const generateLicense = (): string => `${subCode()}-${subCode()}-${subCode()}-${subCode()}`;
|
||||
@@ -1,4 +1,4 @@
|
||||
export const fakeIdentity = {
|
||||
export const activeIdentity = {
|
||||
data: {},
|
||||
links: {},
|
||||
included: [
|
||||
@@ -14,6 +14,44 @@ export const fakeIdentity = {
|
||||
],
|
||||
};
|
||||
|
||||
export const invalidIdentity = {
|
||||
data: {},
|
||||
links: {},
|
||||
included: [{}],
|
||||
};
|
||||
|
||||
export const formerIdentitySucceed = {
|
||||
data: {},
|
||||
links: {},
|
||||
included: [
|
||||
{
|
||||
attributes: {
|
||||
is_monthly: true,
|
||||
campaign_lifetime_support_cents: 500,
|
||||
patron_status: "former_patron",
|
||||
},
|
||||
id: "id",
|
||||
type: "campaign"
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
export const formerIdentityFail = {
|
||||
data: {},
|
||||
links: {},
|
||||
included: [
|
||||
{
|
||||
attributes: {
|
||||
is_monthly: true,
|
||||
campaign_lifetime_support_cents: 1,
|
||||
patron_status: "former_patron",
|
||||
},
|
||||
id: "id",
|
||||
type: "campaign"
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
export const fakeOauth = {
|
||||
access_token: "test_access_token",
|
||||
refresh_token: "test_refresh_token",
|
||||
|
||||
Reference in New Issue
Block a user