Skip to content

Commit dd46666

Browse files
committed
refactor: enhance application validation and add comprehensive tests
- Corrected the spelling of 'dribbble' in application validation. - Added new fields to application test fixtures, including imageUrl and social links. - Expanded integration tests to cover various application creation scenarios, including handling of accepted and rejected applications. - Implemented unit tests for application validation, focusing on phone number, social links, role, and word count validations. - Improved error handling in application service to manage conflicts and database errors effectively.
1 parent 85bd7fd commit dd46666

File tree

5 files changed

+1016
-3
lines changed

5 files changed

+1016
-3
lines changed

middlewares/validators/application.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const validateApplicationData = async (req: CustomRequest, res: CustomResponse,
2020
twitter: joi.string().min(1).optional(),
2121
peerlist: joi.string().min(1).optional(),
2222
behance: joi.string().min(1).optional(),
23-
dribble: joi.string().min(1).optional(),
23+
dribbble: joi.string().min(1).optional(),
2424
})
2525
.optional();
2626

test/fixtures/applications/applications.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ module.exports = () => {
6868
status: "rejected",
6969
createdAt: null,
7070
role: "developer",
71+
imageUrl: "https://example.com/profile1.jpg",
72+
socialLink: {
73+
phoneNo: "+1234567890",
74+
github: "testuser1",
75+
linkedin: "testuser1",
76+
twitter: "testuser1",
77+
instagram: "testuser1",
78+
peerlist: "testuser1",
79+
behance: "testuser1",
80+
dribbble: "testuser1",
81+
},
7182
},
7283
{
7384
college: "Groww",
@@ -116,6 +127,17 @@ module.exports = () => {
116127
status: "rejected",
117128
createdAt: null,
118129
role: "developer",
130+
imageUrl: "https://example.com/profile2.jpg",
131+
socialLink: {
132+
phoneNo: "+1234567891",
133+
github: "testuser2",
134+
linkedin: "testuser2",
135+
twitter: "testuser2",
136+
instagram: "testuser2",
137+
peerlist: "testuser2",
138+
behance: "testuser2",
139+
dribbble: "testuser2",
140+
},
119141
},
120142
{
121143
college: "Groww",
@@ -138,6 +160,17 @@ module.exports = () => {
138160
country: "India",
139161
numberOfHours: 20,
140162
role: "developer",
163+
imageUrl: "https://example.com/profile.jpg",
164+
socialLink: {
165+
phoneNo: "+1234567890",
166+
github: "testuser",
167+
linkedin: "testuser",
168+
twitter: "testuser",
169+
instagram: "testuser",
170+
peerlist: "testuser",
171+
behance: "testuser",
172+
dribbble: "testuser",
173+
},
141174
},
142175
{
143176
firstName: "vinayak",
@@ -158,6 +191,17 @@ module.exports = () => {
158191
"mattis aliquam faucibus purus in massa tempor nec feugiat nisl pretium fusce id velit ut tortor pretium viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare suspendisse sed nisi lacus sed viverra tellus in hac habitasse platea dictumst vestibulum rhoncus est pellentesque elit ullamcorper dignissim cras tincidunt lobortis feugiat vivamus at augue eget arcu dictum varius duis at consectetur lorem donec massa sapien faucibus et molestie ac feugiat sed lectus vestibulum mattis ullamcorper velit sed ullamcorper morbi tincidunt ornare massa eget egestas purus viverra accumsan in nisl nisi scelerisque eu ultrices vitae auctor eu augue ut lectus arcu bibendum at",
159192
foundFrom: "twitter",
160193
role: "developer",
194+
imageUrl: "https://example.com/profile.jpg",
195+
socialLink: {
196+
phoneNo: "+1234567890",
197+
github: "testuser",
198+
linkedin: "testuser",
199+
twitter: "testuser",
200+
instagram: "testuser",
201+
peerlist: "testuser",
202+
behance: "testuser",
203+
dribbble: "testuser",
204+
},
161205
},
162206
];
163207
};

0 commit comments

Comments
 (0)