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

22
test/mocks/gumroadMock.ts Normal file
View 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()}`;

View File

@@ -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",