Add comprehensive tests for role middleware and fix package dependencies
Some checks are pending
Docker Test / test (push) Waiting to run
Some checks are pending
Docker Test / test (push) Waiting to run
This commit is contained in:
parent
64aa924270
commit
bfd432d094
1884 changed files with 384668 additions and 84 deletions
55
node_modules/chai/lib/chai/utils/getOperator.js
generated
vendored
Normal file
55
node_modules/chai/lib/chai/utils/getOperator.js
generated
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
var type = require('type-detect');
|
||||
|
||||
var flag = require('./flag');
|
||||
|
||||
function isObjectType(obj) {
|
||||
var objectType = type(obj);
|
||||
var objectTypes = ['Array', 'Object', 'function'];
|
||||
|
||||
return objectTypes.indexOf(objectType) !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* ### .getOperator(message)
|
||||
*
|
||||
* Extract the operator from error message.
|
||||
* Operator defined is based on below link
|
||||
* https://nodejs.org/api/assert.html#assert_assert.
|
||||
*
|
||||
* Returns the `operator` or `undefined` value for an Assertion.
|
||||
*
|
||||
* @param {Object} object (constructed Assertion)
|
||||
* @param {Arguments} chai.Assertion.prototype.assert arguments
|
||||
* @namespace Utils
|
||||
* @name getOperator
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function getOperator(obj, args) {
|
||||
var operator = flag(obj, 'operator');
|
||||
var negate = flag(obj, 'negate');
|
||||
var expected = args[3];
|
||||
var msg = negate ? args[2] : args[1];
|
||||
|
||||
if (operator) {
|
||||
return operator;
|
||||
}
|
||||
|
||||
if (typeof msg === 'function') msg = msg();
|
||||
|
||||
msg = msg || '';
|
||||
if (!msg) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (/\shave\s/.test(msg)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var isObject = isObjectType(expected);
|
||||
if (/\snot\s/.test(msg)) {
|
||||
return isObject ? 'notDeepStrictEqual' : 'notStrictEqual';
|
||||
}
|
||||
|
||||
return isObject ? 'deepStrictEqual' : 'strictEqual';
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue