-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add test for the profile component #1256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 2 commits
86cbb7a
a278c16
f182754
99fa409
7b668ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const mockTrailer = { | ||
summary: "trailer summary", | ||
description: "trailer description", | ||
video: "trailer video", | ||
duration: 4, | ||
info: { | ||
items: ["item 1", "item 2"], | ||
title: "info title", | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
import { TEAM_FORMATION } from "@/constants/challengeInfo"; | ||
import { metadata, mockCommunity } from "./community"; | ||
import { mockFormat, mockCertificateData, mockCourse, mockLearningModule, mockRatingCriteria } from "./course"; | ||
import { reward } from "./reward"; | ||
import { Submission, User } from "@/types/bounty"; | ||
import { KYCSTATUS } from "@/store/feature/kyc.slice"; | ||
import { Team, TeamMember } from "@/types/challenge"; | ||
|
||
export const fixtureUser = (): User => ({ | ||
id: "user_id", | ||
ref: "ref", | ||
created_at: new Date("2022-05-01T12:00:00Z"), | ||
firstName: "John Doe", | ||
displayName: "John Doe", | ||
uid: "uuid-uuido-232-dex0232-2331", | ||
joined: "14 days ago", | ||
disabled: false, | ||
reputation: 0, | ||
username: "", | ||
lastName: "", | ||
emailVerified: false, | ||
email: "", | ||
kycStatus: KYCSTATUS.PENDING, | ||
}); | ||
|
||
export const challenge = () => ({ | ||
id: "challenge", | ||
ref: "challenge ref", | ||
created_at: new Date("2022-05-01T12:00:00Z"), | ||
updated_at: new Date("2022-05-01T12:00:00Z"), | ||
hint: "Hint", | ||
name: "challenge name", | ||
format: mockFormat, | ||
description: "challenge description", | ||
course: mockCourse, | ||
type: "course", | ||
isTeamChallenge: false, | ||
objectives: ["objectives 1", "Objectives 2", "Objectives 3", "Objectives 4"], | ||
threshold: 8, | ||
community: mockCommunity, | ||
reviewTime: 9, | ||
metadata: metadata, | ||
level: 58, | ||
courses: [mockCourse], | ||
learningModules: [mockLearningModule], | ||
expiresAt: "2025", | ||
reward: reward, | ||
certificateIcon: "certificate", | ||
certificateData: mockCertificateData, | ||
ratingCriteria: [mockRatingCriteria], | ||
timestamp: 6, | ||
maxPoints: 299, | ||
minPoints: 9, | ||
rewards: [reward], | ||
feedbacks: {}, | ||
feedbackInfo: [{}], | ||
bestSubmissions: [{}], | ||
teamLimit: 5, | ||
isHackathon: false, | ||
additionalInfo: { | ||
[TEAM_FORMATION]: { | ||
type: "teamFormation", | ||
text: "Form your team details here", | ||
}, | ||
}, | ||
}); | ||
|
||
export const fixtureSubmission = (): Submission => ({ | ||
length: 0, | ||
id: "submission_id", | ||
ref: "reference", | ||
created_at: new Date("2022-05-01T12:00:00Z"), | ||
updated_at: new Date("2022-05-01T12:00:00Z"), | ||
link: "/submissions/reference", | ||
community: mockCommunity, | ||
user_id: "user_id", | ||
challenge: challenge(), | ||
text: "Submission", | ||
reviewDeadline: new Date(), | ||
metadata: { | ||
evaluation: "", | ||
applicableReward: { | ||
ref: "", | ||
amount: 0, | ||
updated_at: "", | ||
challenge: "", | ||
created_at: "", | ||
id: "", | ||
type: "", | ||
community: "", | ||
timestamp: 0, | ||
token: "", | ||
}, | ||
reviewed: false, | ||
feedbacks: 0, | ||
language: "", | ||
}, | ||
timestamp: 0, | ||
user: fixtureUser(), | ||
reviewable: false, | ||
status: "", | ||
reward: reward, | ||
map: function () { | ||
throw new Error("Function not implemented."); | ||
}, | ||
}); | ||
export const mockInvite = { | ||
created_at: "tuesday", | ||
id: "invite", | ||
ref: "invitation ref", | ||
status: "invitation status", | ||
team_ref: "team reference", | ||
timestamp: 3, | ||
updated_at: "wednesday", | ||
user: fixtureUser(), | ||
user_id: "user id", | ||
} | ||
|
||
export const mockTeamMember: TeamMember = { | ||
created_at: "created_at", | ||
id: "id", | ||
joined_on: "joined_on", | ||
ref: "ref", | ||
team_ref: "team reference", | ||
timestamp: 3, | ||
updated_at: "wednesday", | ||
user: fixtureUser(), | ||
} | ||
|
||
export const mockTeam: Team = { | ||
challenge: challenge(), | ||
challenge_ref: "challenge ref", | ||
created_at: "created at", | ||
id: "id", | ||
locked: true, | ||
name: "Master", | ||
organizer: fixtureUser(), | ||
organizer_id: "organizer id", | ||
invites: [mockInvite], | ||
members: [mockTeamMember], | ||
ref: "", | ||
timestamp: "", | ||
updated_at: "" | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,57 @@ | ||||||
import { Community } from "@/types/community"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optimize import statements. Since these imports are only used for type information, consider using TypeScript's - import { Community } from "@/types/community";
+ import type { Community } from "@/types/community"; Committable suggestion
Suggested change
|
||||||
import { colors } from "./colors"; | ||||||
|
||||||
export const metadata = { | ||||||
invite_id: "abc123", | ||||||
submissions: 5, | ||||||
bestSubmissions: ["submission1", "submission2"], | ||||||
feedbacks: 10, | ||||||
name: "Project XYZ", | ||||||
issuedOn: "2024-01-29T12:00:00Z", | ||||||
image: "image_url", | ||||||
title: "Title of the project", | ||||||
description: "Description of the project", | ||||||
narrative: "Narrative of the project", | ||||||
recipientName: "John Doe", | ||||||
issuerName: "Jane Smith", | ||||||
comment: "This is a comment", | ||||||
linkToWork: "link_to_work", | ||||||
submission: "submission_details", | ||||||
}; | ||||||
|
||||||
const reward = { | ||||||
id: "123456789", | ||||||
ref: "ref123", | ||||||
created_at: new Date("2024-01-29T08:00:00Z"), | ||||||
updated_at: new Date("2024-01-29T08:30:00Z"), | ||||||
challenge: "Challenge Name", | ||||||
type: "SUBMISSION", | ||||||
community: "Community Name", | ||||||
token: "Token ID", | ||||||
stable: true, | ||||||
amount: 100, | ||||||
timestamp: 1643424000, | ||||||
}; | ||||||
|
||||||
export const mockCommunity: Community = { | ||||||
id: "ew-43", | ||||||
ref: "community/ref", | ||||||
created_at: new Date("2022-05-01T12:00:00Z"), | ||||||
updated_at: new Date("2022-05-01T12:00:00Z"), | ||||||
summary: "this is the summary", | ||||||
icon: "public/img/communities/aeternity.svg", | ||||||
name: "aeternity", | ||||||
image: "public/img/communities/aeternity.svg", | ||||||
colors: colors, | ||||||
slug: "ae", | ||||||
active: true, | ||||||
description: "this is a aeternity community", | ||||||
metadata, | ||||||
timestamp: 182044800000, | ||||||
rewards: [reward], | ||||||
reward, | ||||||
courses: 3, | ||||||
duration: 4, | ||||||
can_mint_certificates: true, | ||||||
challenges: 3, | ||||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import { Course, Format, LearningModule, Material } from "@/types/course"; | ||
import { mockTrailer } from "./bounty"; | ||
|
||
|
||
export const Introduction = { | ||
text: "course intro", | ||
}; | ||
|
||
export const mockCertificateData = { | ||
narrative: "course certificate", | ||
icon: "certificate icon", | ||
}; | ||
|
||
export const Rubric = { | ||
id: "id", | ||
ref: "rubric references", | ||
created_at: "Wednesday", | ||
updated_at: "Thursday", | ||
challenge: "Challenge", | ||
text: "Challenge text", | ||
type: "challenge type", | ||
order: 89, | ||
points: 90, | ||
timestamp: 73, | ||
typeSlug: "slug", | ||
}; | ||
|
||
export const mockRatingCriteria = { | ||
name: "rating criteria", | ||
order: 4, | ||
rubric: [Rubric], | ||
maxPoints: 78, | ||
}; | ||
|
||
enum MaterialType { | ||
ADDITIONAL = "ADDITIONAL", | ||
MARKDOWN = "MARKDOWN", | ||
TEXT = "TEXT", | ||
ARTICLE = "ARTICLE", | ||
"EMBEDDED-VIDEO" = "EMBEDDED-VIDEO", | ||
} | ||
export const mockMaterial: Material = { | ||
duration: 3, | ||
subtitle: "material subtitle", | ||
link: "material link", | ||
description: "material description", | ||
title: "material title", | ||
type: MaterialType.ADDITIONAL, | ||
list: [{ link: "Link 1" }], | ||
}; | ||
|
||
export const InteractiveModule = { | ||
ref: "interactive module ref", | ||
title: "interactive module title", | ||
text: "interative text", | ||
closing: { | ||
text: "closing", | ||
title: "title", | ||
}, | ||
items: [ | ||
{ | ||
text: "text", | ||
title: "title", | ||
options: { | ||
text: "text", | ||
isCorrect: true, | ||
}, | ||
question: { | ||
title: "question title", | ||
answers: ["answer 1", "answer 2"], | ||
correct: 2, | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
export const mockLearningModule: LearningModule = { | ||
id: "learningModule id", | ||
ref: "learning module reference", | ||
created_at: new Date("2022-05-01T12:00:00Z"), | ||
updated_at: new Date("2022-05-01T12:00:00Z"), | ||
duration: 4, | ||
description: "learning module description", | ||
objectives: ["objective 1, objective 2"], | ||
title: "learning module title", | ||
community: "learning module community", | ||
materials: [mockMaterial], | ||
timestamp: 3, | ||
order: 4, | ||
course: "Learning module course", | ||
interactiveModules: [InteractiveModule], | ||
}; | ||
|
||
export const mockCourse: Course = { | ||
id: "course", | ||
ref: "course ref", | ||
created_at: new Date("2022-05-01T12:00:00Z"), | ||
updated_at: new Date("2022-05-01T12:00:00Z"), | ||
duration: 3, | ||
summary: "Course description", | ||
level: 3, | ||
name: "course name", | ||
description: "Course description", | ||
objectives: ["course description", "course objectives"], | ||
locale: "English", | ||
community: "community", | ||
slug: "course description slug", | ||
introduction: Introduction, | ||
active: true, | ||
certificateIcon: "certificate", | ||
certificateData: mockCertificateData, | ||
timestamp: 0, | ||
learningModules: [mockLearningModule], | ||
trailer: mockTrailer, | ||
disclaimer: "Course", | ||
items: ["item 1", "item 2"], | ||
faq: [ | ||
{ | ||
description: "faq description", | ||
title: "faq title", | ||
}, | ||
], | ||
prerequisite: { | ||
items: ["item 1", "item 2"], | ||
hint: "prerequisite hint", | ||
}, | ||
translations: [] | ||
}; | ||
|
||
export const mockFormat: Format = { | ||
githubLink: true, | ||
text: true, | ||
disclaimer: true, | ||
}; |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,28 @@ | ||||||||||
import { Feedback } from "@/types/feedback"; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optimize import statements. Since these imports are only used for type information, consider using TypeScript's - import { Feedback } from "@/types/feedback";
- import { fixtureSubmission, fixtureUser } from "./challenge";
- import { reward } from "./reward";
+ import type { Feedback } from "@/types/feedback";
+ import type { fixtureSubmission, fixtureUser } from "./challenge";
+ import type { reward } from "./reward"; Committable suggestion
Suggested change
|
||||||||||
import { fixtureSubmission, fixtureUser } from "./challenge"; | ||||||||||
import { reward } from "./reward"; | ||||||||||
|
||||||||||
export const fixtureFeedback: Feedback = { | ||||||||||
submission: fixtureSubmission(), | ||||||||||
id: "feedback id", | ||||||||||
ref: "feedback ref", | ||||||||||
created_at: new Date("2022-05-01T12:00:00Z"), | ||||||||||
updated_at: "wednesday", | ||||||||||
criteria: ["feedback 1", "feedback 2", "feedback 3"], | ||||||||||
positive: true, | ||||||||||
name: "mima", | ||||||||||
challenge: "TypeScript", | ||||||||||
timestamp: 4, | ||||||||||
description: "feedback description", | ||||||||||
user: fixtureUser(), | ||||||||||
ranking: 3, | ||||||||||
text: "feedback text", | ||||||||||
metadata: { | ||||||||||
evaluation: { | ||||||||||
reward: reward, | ||||||||||
points: 8, | ||||||||||
}, | ||||||||||
language: "en", | ||||||||||
}, | ||||||||||
link: "/feedback" | ||||||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert the function expression to an arrow function for consistency and modern JavaScript practices.
Committable suggestion