Repository navigation
Expand file tree
/
Copy pathstudent.test.ts
More file actions
108 lines (95 loc) · 2.94 KB
/
Copy pathstudent.test.ts
File metadata and controls
108 lines (95 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { describe, expect, it } from 'vitest';
import type {
Education,
Experience,
ParsedResume,
ResumeConfirmResponse,
ResumeUploadResponse,
StudentProfile,
} from './student';
const education: Education = {
institution: 'GLA University',
degree: 'B.Tech',
field: 'Computer Science',
startDate: '2022-08-01',
endDate: '2026-05-31',
};
const experience: Experience = {
company: 'Akoode',
role: 'SWE Intern',
startDate: '2025-06-01',
endDate: '2025-08-31',
description: 'Worked on frontend and API integration.',
};
describe('types/student', () => {
it('accepts valid ParsedResume shape', () => {
const parsedResume: ParsedResume = {
name: 'Sonal Mittal',
phone: '',
skills: ['TypeScript', 'React'],
education: [education],
experience: [experience],
};
expect(parsedResume.skills).toContain('TypeScript');
});
it('accepts StudentProfile with optional fields omitted', () => {
const profile: StudentProfile = {
githubUsername: 'mittalsonal',
name: 'Sonal Mittal',
skills: ['Node.js'],
education: [education],
experience: [experience],
createdAt: new Date('2026-01-01T00:00:00.000Z'),
updatedAt: new Date('2026-01-01T00:00:00.000Z'),
};
expect(profile.phone).toBeUndefined();
expect(profile.resumeUrl).toBeUndefined();
});
it('accepts StudentProfile with all optional fields present', () => {
const profile: StudentProfile = {
githubUsername: 'mittalsonal',
name: 'Sonal Mittal',
phone: '+91-9000000000',
skills: ['Next.js'],
education: [education],
experience: [experience],
resumeUrl: 'https://example.com/resume.pdf',
resumeFileName: 'resume.pdf',
createdAt: new Date('2026-01-01T00:00:00.000Z'),
updatedAt: new Date('2026-01-02T00:00:00.000Z'),
};
expect(profile.resumeFileName).toBe('resume.pdf');
});
it('preserves ResumeUploadResponse success and error unions', () => {
const okResponse: ResumeUploadResponse = {
success: true,
data: {
name: 'Sonal Mittal',
phone: '',
skills: ['React'],
education: [education],
experience: [experience],
},
fileName: 'resume.pdf',
};
const errorResponse: ResumeUploadResponse = {
success: false,
error: 'Upload failed',
};
expect(okResponse.success).toBe(true);
expect(errorResponse.error).toBe('Upload failed');
});
it('accepts ResumeConfirmResponse success and failure payloads', () => {
const successPayload: ResumeConfirmResponse = { success: true };
const failurePayload: ResumeConfirmResponse = {
success: false,
error: 'Confirmation failed',
};
expect(successPayload.success).toBe(true);
expect(failurePayload.error).toBe('Confirmation failed');
});
});