github
311 of 485 branches covered (64.12%)
Branch coverage included in aggregate %.
9 of 39 new or added lines in 5 files covered. (23.08%)
155 existing lines in 5 files now uncovered.2412 of 3300 relevant lines covered (73.09%)
2538.02 hits per line
UNCOV
1
|
import Task from '../routes/task.js'; |
|
UNCOV
2
|
import error from './error.js'; |
× |
UNCOV
3
|
|
× |
UNCOV
4
|
// eslint-disable-next-line complexity
|
× |
UNCOV
5
|
const checkMiddleware = (
|
× |
UNCOV
6
|
type: 'pre' | 'post', |
× |
UNCOV
7
|
route: Task, |
× |
UNCOV
8
|
) => { |
× |
UNCOV
9
|
if (typeof route[type] === 'undefined') { |
× |
UNCOV
10
|
return true; |
× |
UNCOV
11
|
} |
× |
12 |
const data = route[type];
|
× |
13 |
delete route[type];
|
× |
UNCOV
14
|
if (typeof data !== 'object' || ! Array.isArray(data,)) { |
× |
15 |
error(`invalid_${ type }_definition`, route.id,); |
× |
16 |
return false; |
× |
17 |
} |
× |
18 |
for (const middleware of data) { |
× |
19 |
if (typeof middleware !== 'string') { |
× |
20 |
error(`invalid_${ type }_definition`, route.id,); |
× |
21 |
return false; |
× |
22 |
} |
× |
23 |
} |
× |
24 |
return true; |
× |
25 |
}; |
× |
UNCOV
26
|
|
× |
UNCOV
27
|
export default checkMiddleware; |
× |