jest-matcher-utils
Advanced tools
Comparing version 14.0.0 to 14.2.0-alpha.ca8bfb6e
@@ -19,25 +19,25 @@ /** | ||
if (typeof value === 'undefined') { | ||
return 'undefined';} else | ||
if (value === null) { | ||
return 'null';} else | ||
if (Array.isArray(value)) { | ||
return 'array';} else | ||
if (typeof value === 'boolean') { | ||
return 'boolean';} else | ||
if (typeof value === 'function') { | ||
return 'function';} else | ||
if (typeof value === 'number') { | ||
return 'number';} else | ||
if (typeof value === 'string') { | ||
return 'string';} else | ||
if (typeof value === 'object') { | ||
return 'undefined'; | ||
} else if (value === null) { | ||
return 'null'; | ||
} else if (Array.isArray(value)) { | ||
return 'array'; | ||
} else if (typeof value === 'boolean') { | ||
return 'boolean'; | ||
} else if (typeof value === 'function') { | ||
return 'function'; | ||
} else if (typeof value === 'number') { | ||
return 'number'; | ||
} else if (typeof value === 'string') { | ||
return 'string'; | ||
} else if (typeof value === 'object') { | ||
return 'object'; | ||
// $FlowFixMe https://github.com/facebook/flow/issues/1015 | ||
} else if (typeof value === 'symbol') { | ||
return 'symbol';} | ||
return 'symbol'; | ||
} | ||
throw new Error(`value of unknown type: ${ value }`); | ||
}; | ||
throw new Error(`value of unknown type: ${ value }`);}; | ||
// Convert to JSON removing circular references and | ||
@@ -50,38 +50,38 @@ // converting JS values to strings. | ||
if ( | ||
value && | ||
value.constructor && | ||
value.constructor.name === 'RegExp') | ||
value && | ||
value.constructor && | ||
value.constructor.name === 'RegExp') | ||
{ | ||
return value.toString();} else | ||
{ | ||
return value.toString(); | ||
} else { | ||
if (set.has(value)) { | ||
return '[Circular]';} | ||
set.add(value);}} else | ||
if (typeof value === 'function') { | ||
return value.toString();} else | ||
if (typeof value === 'undefined') { | ||
return '[Circular]'; | ||
} | ||
set.add(value); | ||
} | ||
} else if (typeof value === 'function') { | ||
return value.toString(); | ||
} else if (typeof value === 'undefined') { | ||
return 'undefined'; | ||
// $FlowFixMe symbols are not supported by flow yet | ||
} else if (typeof value === 'symbol') { | ||
return value.toString();} else | ||
if (value === Infinity) { | ||
return 'Infinity';} else | ||
if (value === -Infinity) { | ||
return '-Infinity';} else | ||
if (Number.isNaN(value)) { | ||
return 'NaN';} | ||
return value.toString(); | ||
} else if (value === Infinity) { | ||
return 'Infinity'; | ||
} else if (value === -Infinity) { | ||
return '-Infinity'; | ||
} else if (Number.isNaN(value)) { | ||
return 'NaN'; | ||
} | ||
return value; | ||
}); | ||
}; | ||
return value;});}; | ||
const ensureNoExpected = (expected, matcherName) => { | ||
matcherName || (matcherName = 'This'); | ||
if (typeof expected !== 'undefined') { | ||
throw new Error(`${ matcherName } matcher does not accept any arguments`);}}; | ||
throw new Error(`${ matcherName } matcher does not accept any arguments`); | ||
} | ||
}; | ||
const ensureActualIsNumber = (actual, matcherName) => { | ||
@@ -91,8 +91,8 @@ matcherName || (matcherName = 'This matcher'); | ||
throw new Error( | ||
`${ matcherName } actual value should be a number. ` + | ||
`'${ typeof actual }' was passed`);}}; | ||
`${ matcherName } actual value should be a number. ` + | ||
`'${ typeof actual }' was passed`); | ||
} | ||
}; | ||
const ensureExpectedIsNumber = (expected, matcherName) => { | ||
@@ -102,19 +102,19 @@ matcherName || (matcherName = 'This matcher'); | ||
throw new Error( | ||
`${ matcherName } expected value should be a number. ` + | ||
`'${ typeof expected }' was passed`);}}; | ||
`${ matcherName } expected value should be a number. ` + | ||
`'${ typeof expected }' was passed`); | ||
} | ||
}; | ||
const ensureNumbers = (actual, expected, matcherName) => { | ||
ensureActualIsNumber(actual, matcherName); | ||
ensureExpectedIsNumber(expected, matcherName);}; | ||
ensureExpectedIsNumber(expected, matcherName); | ||
}; | ||
module.exports = { | ||
getType, | ||
stringify, | ||
ensureNoExpected, | ||
ensureActualIsNumber, | ||
ensureExpectedIsNumber, | ||
module.exports = { | ||
getType, | ||
stringify, | ||
ensureNoExpected, | ||
ensureActualIsNumber, | ||
ensureExpectedIsNumber, | ||
ensureNumbers }; |
{ | ||
"name": "jest-matcher-utils", | ||
"description": "A set of utility functions for jest-matchers and related packages", | ||
"version": "14.0.0", | ||
"version": "14.2.0-alpha.ca8bfb6e", | ||
"repository": { | ||
@@ -11,7 +11,2 @@ "type": "git", | ||
"main": "build/index.js", | ||
"jest": { | ||
"rootDir": "./src", | ||
"scriptPreprocessor": "../../babel-jest", | ||
"testEnvironment": "node" | ||
}, | ||
"scripts": { | ||
@@ -18,0 +13,0 @@ "test": "../../packages/jest-cli/bin/jest.js" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102
3598
2