• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ULL-ESIT-INF-DSI-2526 / grp02-medcore-api-groupd / 25635998054

10 May 2026 06:09PM UTC coverage: 91.312% (+4.8%) from 86.473%
25635998054

push

github

DiegoPrietoG
feat: add validation for staff ID format in readStaffByIdController and update tests for readStaff functionality

106 of 112 branches covered (94.64%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 2 files covered. (100.0%)

3 existing lines in 1 file now uncovered.

430 of 475 relevant lines covered (90.53%)

8.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.46
/src/controller/staff/modifyStaffController.ts
1
import { Request, Response } from 'express';
2
import iStaff  from '../../models/staff/staffInterface.js';
3
import { modifyStaff} from '../../services/staff/modifyStaff.js';
4
import mongoose from 'mongoose';
5

6
/**
7
 * Controlador para modificar un miembro del personal por un filtro.
8
 * @param req - Request
9
 * @param res - Response
10
 * @returns Retorna un error o el miembro dle personal modificado por el filtro.
11
 */
12
export async function modifyStaffController(req: Request, res: Response) {
13
  try {
6✔
14
    const { name, specialty } = req.query;
6✔
15

16
    const filter: Partial<iStaff> = {};
6✔
17

18
    if (typeof name === 'string') filter.name = name;
6✔
19
    if (typeof specialty === 'string') {
6✔
20
      filter.specialty = specialty as iStaff['specialty'];
1✔
21
    }
22
    
23
    if (Object.keys(filter).length === 0) {
6✔
UNCOV
24
      return res.status(400).json({ error: 'No valid filter provided' });
×
25
    }
26

27
    const result = await modifyStaff(filter, req.body);
6✔
28

29
    if (!result) {
4✔
30
      return res.status(404).json({ error: 'Staff not found' });
2✔
31
    }
32

33
    return res.status(200).json(result);
2✔
34

35
  } catch (error: unknown) {
36
    if (error instanceof mongoose.Error.ValidationError) {
2✔
37
      return res.status(400).json({ error: error.message });
1✔
38
    }
39

40
    if (error instanceof mongoose.Error.CastError) {
1✔
UNCOV
41
      return res.status(400).json({ error: error.message });
×
42
    }
43

44
    if (error instanceof Error) {
1✔
45
      return res.status(500).json({ error: error.message });
1✔
46
    }
47

UNCOV
48
    return res.status(500).json({ error: 'Internal Server Error' });
×
49
  }
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc