Skip to content

Commit f18bf3d

Browse files
refactor: update feedback test with store mocked values
1 parent 42f533b commit f18bf3d

File tree

13 files changed

+468
-20
lines changed

13 files changed

+468
-20
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: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
import { mockFormat, mockCertificateData, mockCourse, mockLearningModule, mockRatingCriteria } from "./course";
2+
import { reward } from "./reward";
3+
import { KYCSTATUS } from "@/store/feature/kyc.slice";
4+
import { Submission, User } from "@/types/bounty";
5+
import { AdditionalInfo, Challenge } from "@/types/course";
6+
import { TEAM_FORMATION } from "@/constants/challengeInfo";
7+
import { Team, TeamMember } from "@/types/challenge";
8+
import { community, metadata } from "./community";
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: community,
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+
}
71+
});
72+
73+
export const submission = (): Submission => ({
74+
length: 0,
75+
id: "submission_id",
76+
ref: "reference",
77+
created_at: new Date("2022-05-01T12:00:00Z"),
78+
updated_at: new Date("2022-05-01T12:00:00Z"),
79+
link: "/submissions/reference",
80+
community: community,
81+
user_id: "user_id",
82+
challenge: challenge(),
83+
text: "Submission",
84+
reviewDeadline: new Date("2022-05-01T12:00:00Z"),
85+
metadata: {
86+
evaluation: "",
87+
applicableReward: {
88+
ref: "",
89+
amount: 0,
90+
updated_at: "",
91+
challenge: "",
92+
created_at: "",
93+
id: "",
94+
type: "",
95+
community: "",
96+
timestamp: 0,
97+
token: "",
98+
},
99+
reviewed: false,
100+
feedbacks: 0,
101+
language: "",
102+
},
103+
timestamp: 0,
104+
user: mockUser(),
105+
reviewable: false,
106+
status: "",
107+
reward: reward,
108+
map: function () {
109+
throw new Error("Function not implemented.");
110+
},
111+
});
112+
113+
export const mockInvite = {
114+
created_at: "tuesday",
115+
id: "invite",
116+
ref: "invitation ref",
117+
status: "invitation status",
118+
team_ref: "team reference",
119+
timestamp: 3,
120+
updated_at: "wednesday",
121+
user: mockUser(),
122+
user_id: "user id",
123+
}
124+
125+
export const mockTeamMember: TeamMember = {
126+
created_at: "created_at",
127+
id: "id",
128+
joined_on: "joined_on",
129+
ref: "ref",
130+
team_ref: "team reference",
131+
timestamp: 3,
132+
updated_at: "wednesday",
133+
user: mockUser(),
134+
}
135+
136+
export const mockTeam: Team = {
137+
challenge: challenge(),
138+
challenge_ref: "challenge ref",
139+
created_at: "created at",
140+
id: "id",
141+
locked: true,
142+
name: "Master",
143+
organizer: mockUser(),
144+
organizer_id: "organizer id",
145+
invites: [mockInvite],
146+
members: [mockTeamMember],
147+
ref: "",
148+
timestamp: "",
149+
updated_at: ""
150+
}
151+
152+
export const challengeSliceData = {
153+
current: challenge(),
154+
list: [challenge()],
155+
submission: submission(),
156+
loading: false
157+
158+
}

__mocks__/colors.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const colors = {
1+
import { Colors } from "@/types/community";
2+
3+
export const colors: Colors = {
24
textAccent: "--tm-text",
35
text: "--tm-text",
46
accent: "--tm-accent",

__mocks__/community.ts

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

__mocks__/course.ts

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

0 commit comments

Comments
 (0)