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

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

10 May 2026 12:08PM UTC coverage: 87.197% (-0.5%) from 87.738%
25628398609

push

github

eduzu
Merge branch 'main' of github.com:ULL-ESIT-INF-DSI-2526/grp02-medcore-api-groupd
Medication controllers and basic testing

99 of 109 branches covered (90.83%)

Branch coverage included in aggregate %.

279 of 320 new or added lines in 31 files covered. (87.19%)

1 existing line in 1 file now uncovered.

405 of 469 relevant lines covered (86.35%)

7.92 hits per line

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

92.59
/src/controller/staff/deleteStaffController.ts
1
import { Response } from 'express';
2
import iStaff  from '../../models/staff/staffInterface.js';
3
import { deleteStaff } from '../../services/staff/deleteStaff.js';
4
import mongoose from 'mongoose';
5

6
/**
7
 * Elimina un miembro del personal por un filtro.
8
 * @param req - Request
9
 * @param res - Response
10
 * @returns Retorna un error o el miembro del personal eliminado por el filtro.
11
 */
12
export async function deleteStaffController(req :  {query : {name? : string, specialty? : string}}, res : Response) {
13
    try {
6✔
14
        const { name, specialty } = req.query;
6✔
15
        const filter : Partial<iStaff> = {};
6✔
16

17
        if (typeof name === 'string') filter.name = name;
6✔
18
        if (typeof specialty === 'string') {
6✔
19
            const validSpecialties = ["medicina general", "cardiología", "traumatología", "pediatría", "oncología", "urgencias"];
2✔
20
            if (!validSpecialties.includes(specialty)) {
2✔
21
                return res.status(400).json({ error: `${specialty} is not a valid enum value` });
1✔
22
            }
23
            filter.specialty = specialty as iStaff['specialty'];
1✔
24
        }
25

26
        if (Object.keys(filter).length === 0) {
5✔
27
            return res.status(400).json({ error: 'No valid filter provided' });
1✔
28
        }
29

30
        const result = await deleteStaff(filter);
4✔
31
        if (!result) {
3✔
32
            return res.status(404).json({ error: 'Staff not found' });
1✔
33
        }
34
        return res.status(200).json(result);
2✔
35
    } catch (error : unknown) {
36
        if ( error instanceof mongoose.Error.ValidationError) {
1✔
NEW
37
            return res.status(400).json({ error: error.message });
×
38
        }
39
        if (error instanceof Error) {
1✔
40
            return res.status(500).json({ error: error.message });
1✔
41
        }
NEW
42
        return res.status(500).json({ error: 'Internal Server Error' });
×
43
    }
44
}
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