sendou.ink/prisma/mocks/plus.ts
Kalle (Sendou) 29377e21f5 closes #330
2021-04-02 00:27:49 +03:00

151 lines
3.0 KiB
TypeScript

import { PlusRegion, Prisma } from "@prisma/client";
import plusStatusFactory from "../factories/plusStatus";
import plusSuggestionFactory from "../factories/plusSuggestion";
import plusVotingSummaryFactory from "../factories/plusVotingSummary";
// TODO: All this data is currently hard-coded so that Cypress tests will pass.
// In the future, we could allow the data generated by these factories be more random, and
// update the tests so that they are responsible for creating the specific data that they want to check.
export const getPlusStatusesData = (): Prisma.PlusStatusCreateManyInput[] => {
return [
{
userId: 1,
canVouchAgainAfter: new Date(Date.UTC(2020, 1, 1)),
},
{
userId: 2,
},
{
userId: 3,
},
{
userId: 4,
},
{
userId: 5,
},
{
userId: 6,
membershipTier: 2,
vouchTier: 1,
},
{
userId: 7,
membershipTier: 2,
},
{
userId: 8,
membershipTier: 2,
},
{
userId: 9,
membershipTier: 2,
},
{
userId: 10,
},
{
userId: 333,
region: PlusRegion.EU,
membershipTier: 2,
canVouchAgainAfter: new Date(Date.UTC(2030, 1, 1)),
canVouchFor: 2,
},
{
userId: 999,
region: PlusRegion.EU,
canVouchFor: 1,
membershipTier: 1,
},
].map((params) => {
return plusStatusFactory.build(params);
});
};
export const getPlusSuggestionsData = (): Prisma.PlusSuggestionCreateManyInput[] => {
return [
plusSuggestionFactory.build({
description: "yooo so cracked",
tier: 2,
suggestedId: 10,
suggesterId: 1,
}),
];
};
export const getPlusVotingSummaryData = (): Prisma.PlusVotingSummaryCreateManyInput[] => {
return [
{
userId: 1,
countsEU: [0, 0, 0, 3],
countsNA: [0, 0, 2, 0],
},
{
userId: 2,
countsEU: [0, 3, 0, 0],
countsNA: [2, 0, 0, 0],
},
{
userId: 3,
countsEU: [1, 1, 1, 0],
countsNA: [0, 1, 1, 0],
},
{
userId: 4,
countsEU: [0, 1, 2, 0],
countsNA: [2, 0, 0, 0],
},
{
userId: 5,
countsEU: [1, 0, 1, 1],
countsNA: [0, 2, 0, 0],
},
{
userId: 6,
wasVouched: true,
countsEU: [0, 3, 0, 0],
countsNA: [2, 0, 0, 0],
},
{
userId: 7,
wasVouched: true,
countsEU: [0, 0, 0, 3],
countsNA: [0, 0, 2, 0],
},
// +2
{
userId: 6,
tier: 2,
countsEU: [0, 0, 2, 0],
countsNA: [0, 0, 0, 2],
},
{
userId: 7,
tier: 2,
countsEU: [0, 1, 0, 1],
countsNA: [0, 1, 1, 0],
},
{
userId: 8,
tier: 2,
countsEU: [0, 2, 0, 0],
countsNA: [0, 0, 2, 0],
},
{
userId: 9,
tier: 2,
countsEU: [1, 1, 0, 0],
countsNA: [0, 2, 0, 0],
},
{
userId: 10,
tier: 2,
countsEU: [0, 0, 2, 0],
countsNA: [0, 0, 0, 2],
},
].map((params) => {
return plusVotingSummaryFactory.build(params);
});
};