Skip to content

Commit 238c0aa

Browse files
authored
test(student-profile): add empty fallback coverage (JhaSourav07#2975)
## Description Fixes JhaSourav07#2903 Added empty fallback test coverage for `models/StudentProfile.ts`. ### Tests Added * Verifies optional `phone` field uses an empty string fallback. * Verifies `skills` is configured as an array field. * Verifies `education` is configured as an array field. * Verifies `experience` is configured as an array field. * Confirms experience schema path exists for empty fallback validation. ## Pillar * [ ] 🎨 Pillar 1 — New Theme Design * [ ] 📐 Pillar 2 — Geometric SVG Improvement * [ ] 🕐 Pillar 3 — Timezone Logic Optimization * [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A (Test-only changes) ## Checklist before requesting a review: * [x] I have read the `CONTRIBUTING.md` file. * [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). * [ ] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). * [x] My commits follow the Conventional Commits format. * [ ] I have updated `README.md` if I added a new theme or URL parameter. (Not applicable) * [x] I have starred the repo. * [x] I have made sure that I have only one commit to merge in this PR. * [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard. (Not applicable) * [ ] (Recommended) I joined the CommitPulse Discord community.
2 parents dd640d5 + 6597a84 commit 238c0aa

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import mongoose from 'mongoose';
2+
import { describe, expect, it } from 'vitest';
3+
import { StudentProfile } from './StudentProfile';
4+
5+
describe('StudentProfile Empty Fallback', () => {
6+
it('uses empty string as default phone value', () => {
7+
const phonePath = StudentProfile.schema.path('phone') as mongoose.SchemaType & {
8+
options: Record<string, unknown>;
9+
};
10+
11+
expect(phonePath.options.default).toBe('');
12+
});
13+
14+
it('uses empty string as default experience description', () => {
15+
const experiencePath = StudentProfile.schema.path('experience');
16+
17+
expect(experiencePath).toBeDefined();
18+
});
19+
20+
it('allows skills to exist as an empty array', () => {
21+
const skillsPath = StudentProfile.schema.path('skills') as unknown as {
22+
instance: string;
23+
};
24+
25+
expect(skillsPath.instance).toBe('Array');
26+
});
27+
28+
it('allows education to exist as an empty array', () => {
29+
const educationPath = StudentProfile.schema.path('education') as unknown as {
30+
instance: string;
31+
};
32+
33+
expect(educationPath.instance).toBe('Array');
34+
});
35+
36+
it('allows experience to exist as an empty array', () => {
37+
const experiencePath = StudentProfile.schema.path('experience') as unknown as {
38+
instance: string;
39+
};
40+
41+
expect(experiencePath.instance).toBe('Array');
42+
});
43+
});

0 commit comments

Comments
 (0)