The module commands/util has some unit tests, but some functions are not covered at all. The tests are in the file src/commands/__test__/util.test.js and the tests can just be added to that file.
The test coverage can be checked by running the following script:
npm run test:coverage
Functions that need coverage
checkRole.
makePipe.
makePipe is slightly more complex to test. It receives a first parameter that can be any of string, RegExp or function and an arbitrary number of parameters that are functions. These things should be tested:
When the first parameter is a string, it validates that the message contains the given string.
When the first parameter is a RegExp, it validates that the message matches the given regex.
When the first parameter is a function, it validates that the function invoked on the message returns true.
When the first parameter has another type, it throws an error.
When one of the functions passed as arguments returns false, it doesn't invoke the subsequent functions.
When none of the functions passed as arguments returns false, all of them are invoked.
The module
commands/util
has some unit tests, but some functions are not covered at all. The tests are in the filesrc/commands/__test__/util.test.js
and the tests can just be added to that file.The test coverage can be checked by running the following script:
Functions that need coverage
checkRole
.makePipe
.makePipe
is slightly more complex to test. It receives a first parameter that can be any ofstring
,RegExp
orfunction
and an arbitrary number of parameters that are functions. These things should be tested:string
, it validates that the message contains the given string.RegExp
, it validates that the message matches the given regex.function
, it validates that the function invoked on the message returns true.false
, it doesn't invoke the subsequent functions.false
, all of them are invoked.