Skip to content

Commit ecaba88

Browse files
committed
feat: add tests for submission card
1 parent 247cf8b commit ecaba88

File tree

20 files changed

+570
-22
lines changed

20 files changed

+570
-22
lines changed

__mocks__/bounty.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
export const mockTrailer = {
3+
summary: "trailer summary",
4+
description: "trailer descriptio",
5+
video: "trailer video",
6+
duration: 4,
7+
info: {
8+
items: ["item 1", "item 2"],
9+
title: "info title",
10+
},
11+
};

__mocks__/challenge.ts

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
import { mockFormat, mockCertificateData, mockCourse, mockLearningModule, mockRatingCriteria } from "./course";
2+
import { mockCommunity, metadata } from "./community";
3+
import { reward } from "./reward";
4+
import { KYCSTATUS } from "@/store/feature/kyc.slice";
5+
import { Evaluation, Submission, User } from "@/types/bounty";
6+
import { AdditionalInfo, Challenge } from "@/types/course";
7+
import { GRADING_CRITERIA, TEAM_FORMATION } from "@/constants/challengeInfo";
8+
import { Team, TeamMember } from "@/types/challenge";
9+
10+
export const mockUser = (): User => ({
11+
id: "user_id",
12+
ref: "ref",
13+
created_at: new Date("2022-05-01T12:00:00Z"),
14+
firstName: "John Doe",
15+
displayName: "John Doe",
16+
uid: "uuid-uuido-232-dex0232-2331",
17+
joined: "14 days ago",
18+
disabled: false,
19+
reputation: 0,
20+
username: "",
21+
lastName: "",
22+
emailVerified: false,
23+
email: "",
24+
kycStatus: KYCSTATUS.PENDING,
25+
});
26+
27+
export const mockAdditionalInfo: { [type: string]: AdditionalInfo } = {
28+
type: { type: "additional type", text: "additional text" },
29+
};
30+
31+
export const challenge = (): Challenge => ({
32+
id: "challenge",
33+
ref: "challenge ref",
34+
created_at: new Date("2022-05-01T12:00:00Z"),
35+
updated_at: new Date("2022-05-01T12:00:00Z"),
36+
hint: "Hint",
37+
name: "challenge name",
38+
format: mockFormat,
39+
description: "challenge description",
40+
course: mockCourse,
41+
type: "course",
42+
isTeamChallenge: false,
43+
objectives: ["objectives 1", "Objectives 2", "Objectives 3", "Objectives 4"],
44+
threshold: 8,
45+
community: mockCommunity,
46+
reviewTime: 9,
47+
metadata: metadata,
48+
level: 58,
49+
courses: [mockCourse],
50+
learningModules: [mockLearningModule],
51+
expiresAt: "2025",
52+
reward: reward,
53+
certificateIcon: "certificate",
54+
certificateData: mockCertificateData,
55+
ratingCriteria: [mockRatingCriteria],
56+
timestamp: 6,
57+
maxPoints: 299,
58+
minPoints: 9,
59+
rewards: [reward],
60+
feedbacks: {},
61+
feedbackInfo: [{}],
62+
bestSubmissions: [{}],
63+
teamLimit: 5,
64+
isHackathon: false,
65+
additionalInfo: {
66+
[TEAM_FORMATION]: {
67+
type: "teamFormation",
68+
text: "Form your team details here",
69+
},
70+
[GRADING_CRITERIA]: { type: "teamFormation", text: "Sample grading criteria text" },
71+
},
72+
});
73+
74+
export const evaluation = (): Evaluation => ({
75+
evaluator: mockUser(),
76+
created_at: new Date("2022-05-01T12:00:00Z"),
77+
comment: "comment",
78+
criteria: [],
79+
metadata: {
80+
language: "language",
81+
},
82+
points: 10,
83+
totalPoints: 1,
84+
reward: {
85+
amount: 10,
86+
token: "token",
87+
},
88+
});
89+
90+
export const submission = (): Submission => ({
91+
length: 0,
92+
id: "submission_id",
93+
ref: "reference",
94+
created_at: new Date("2022-05-01T12:00:00Z"),
95+
updated_at: new Date("2022-05-01T12:00:00Z"),
96+
link: "/submissions/reference",
97+
community: mockCommunity,
98+
user_id: "user_id",
99+
challenge: challenge(),
100+
text: "Submission",
101+
reviewDeadline: new Date(),
102+
metadata: {
103+
evaluation: {
104+
points: 8,
105+
reward: {},
106+
score: 80,
107+
totalPoints: 0,
108+
},
109+
applicableReward: {
110+
ref: "",
111+
amount: 0,
112+
updated_at: "",
113+
challenge: "",
114+
created_at: "",
115+
id: "",
116+
type: "",
117+
community: "",
118+
timestamp: 0,
119+
token: "",
120+
},
121+
reviewed: false,
122+
feedbacks: 0,
123+
language: "",
124+
},
125+
evaluation: evaluation(),
126+
timestamp: 0,
127+
user: mockUser(),
128+
reviewable: false,
129+
status: "",
130+
reward: reward,
131+
map: function () {
132+
throw new Error("Function not implemented.");
133+
},
134+
});
135+
136+
export const mockInvite = {
137+
created_at: "tuesday",
138+
id: "invite",
139+
ref: "invitation ref",
140+
status: "invitation status",
141+
team_ref: "team reference",
142+
timestamp: 3,
143+
updated_at: "wednesday",
144+
user: mockUser(),
145+
user_id: "user id",
146+
};
147+
148+
export const mockTeamMember: TeamMember = {
149+
created_at: "created_at",
150+
id: "id",
151+
joined_on: "joined_on",
152+
ref: "ref",
153+
team_ref: "team reference",
154+
timestamp: 3,
155+
updated_at: "wednesday",
156+
user: mockUser(),
157+
};
158+
159+
export const mockTeam: Team = {
160+
challenge: challenge(),
161+
challenge_ref: "challenge ref",
162+
created_at: "created at",
163+
id: "id",
164+
locked: true,
165+
name: "Master",
166+
organizer: mockUser(),
167+
organizer_id: "organizer id",
168+
invites: [mockInvite],
169+
members: [mockTeamMember],
170+
ref: "",
171+
timestamp: "",
172+
updated_at: "",
173+
};

__mocks__/community.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { Community } from "@/types/community";
2+
import { colors } from "./colors";
3+
4+
export const metadata = {
5+
invite_id: "abc123",
6+
submissions: 5,
7+
bestSubmissions: ["submission1", "submission2"],
8+
feedbacks: 10,
9+
name: "Project XYZ",
10+
issuedOn: "2024-01-29T12:00:00Z",
11+
image: "image_url",
12+
title: "Title of the project",
13+
description: "Description of the project",
14+
narrative: "Narrative of the project",
15+
recipientName: "John Doe",
16+
issuerName: "Jane Smith",
17+
comment: "This is a comment",
18+
linkToWork: "link_to_work",
19+
submission: "submission_details",
20+
};
21+
22+
const reward = {
23+
id: "123456789",
24+
ref: "ref123",
25+
created_at: new Date("2024-01-29T08:00:00Z"),
26+
updated_at: new Date("2024-01-29T08:30:00Z"),
27+
challenge: "Challenge Name",
28+
type: "SUBMISSION",
29+
community: "Community Name",
30+
token: "Token ID",
31+
stable: true,
32+
amount: 100,
33+
timestamp: 1643424000,
34+
};
35+
36+
export const mockCommunity: Community = {
37+
id: "ew-43",
38+
ref: "community/ref",
39+
created_at: new Date("2022-05-01T12:00:00Z"),
40+
updated_at: new Date("2022-05-01T12:00:00Z"),
41+
summary: "this is the summary",
42+
icon: "public/img/communities/aeternity.svg",
43+
name: "aeternity",
44+
image: "public/img/communities/aeternity.svg",
45+
colors: colors,
46+
slug: "ae",
47+
active: true,
48+
description: "this is a aeternity community",
49+
metadata,
50+
timestamp: 182044800000,
51+
rewards: [reward],
52+
reward,
53+
courses: 3,
54+
duration: 4,
55+
can_mint_certificates: true,
56+
challenges: 3,
57+
};

__mocks__/course.ts

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import { Course, Format, LearningModule, Material } from "@/types/course";
2+
import { mockTrailer } from "./bounty";
3+
4+
5+
export const Introduction = {
6+
text: "course intro",
7+
};
8+
9+
export const mockCertificateData = {
10+
narrative: "course certificate",
11+
icon: "certificate icon",
12+
};
13+
14+
export const Rubric = {
15+
id: "id",
16+
ref: "rubric references",
17+
created_at: "Wednesday",
18+
updated_at: "Thursday",
19+
challenge: "Challenge",
20+
text: "Challenge text",
21+
type: "challenge type",
22+
order: 89,
23+
points: 90,
24+
timestamp: 73,
25+
typeSlug: "slug",
26+
};
27+
28+
export const mockRatingCriteria = {
29+
name: "rating criteria",
30+
order: 4,
31+
rubric: [Rubric],
32+
maxPoints: 78,
33+
};
34+
35+
enum MaterialType {
36+
ADDITIONAL = "ADDITIONAL",
37+
MARKDOWN = "MARKDOWN",
38+
TEXT = "TEXT",
39+
ARTICLE = "ARTICLE",
40+
"EMBEDDED-VIDEO" = "EMBEDDED-VIDEO",
41+
}
42+
export const mockMaterial: Material = {
43+
duration: 3,
44+
subtitle: "material subtitle",
45+
link: "material link",
46+
description: "material description",
47+
title: "material title",
48+
type: MaterialType.ADDITIONAL,
49+
list: [{ link: "Link 1" }],
50+
};
51+
52+
export const InteractiveModule = {
53+
ref: "interactive module ref",
54+
title: "interactive module title",
55+
text: "interative text",
56+
closing: {
57+
text: "closing",
58+
title: "title",
59+
},
60+
items: [
61+
{
62+
text: "text",
63+
title: "title",
64+
options: {
65+
text: "text",
66+
isCorrect: true,
67+
},
68+
question: {
69+
title: "question title",
70+
answers: ["answer 1", "answer 2"],
71+
correct: 2,
72+
},
73+
},
74+
],
75+
};
76+
77+
export const mockLearningModule: LearningModule = {
78+
id: "learningModule id",
79+
ref: "learning module reference",
80+
created_at: new Date("2022-05-01T12:00:00Z"),
81+
updated_at: new Date("2022-05-01T12:00:00Z"),
82+
duration: 4,
83+
description: "learning module description",
84+
objectives: ["objective 1, objective 2"],
85+
title: "learning module title",
86+
community: "learning module community",
87+
materials: [mockMaterial],
88+
timestamp: 3,
89+
order: 4,
90+
course: "Learning module course",
91+
interactiveModules: [InteractiveModule],
92+
};
93+
94+
export const mockCourse: Course = {
95+
id: "course",
96+
ref: "course ref",
97+
created_at: new Date("2022-05-01T12:00:00Z"),
98+
updated_at: new Date("2022-05-01T12:00:00Z"),
99+
duration: 3,
100+
summary: "Course description",
101+
level: 3,
102+
name: "course name",
103+
description: "Course description",
104+
objectives: ["course description", "course objectives"],
105+
locale: "English",
106+
community: "community",
107+
slug: "course description slug",
108+
introduction: Introduction,
109+
active: true,
110+
certificateIcon: "certificate",
111+
certificateData: mockCertificateData,
112+
timestamp: 0,
113+
learningModules: [mockLearningModule],
114+
trailer: mockTrailer,
115+
disclaimer: "Course",
116+
items: ["item 1", "item 2"],
117+
faq: [
118+
{
119+
description: "faq description",
120+
title: "faq title",
121+
},
122+
],
123+
prerequisite: {
124+
items: ["item 1", "item 2"],
125+
hint: "prerequisite hint",
126+
},
127+
};
128+
129+
export const mockFormat: Format = {
130+
githubLink: true,
131+
text: true,
132+
disclaimer: true,
133+
};

0 commit comments

Comments
 (0)