gen-secure-password
Version:
generate secure password using CryptoJS
31 lines (27 loc) • 902 B
JavaScript
const { expect } = require('@jest/globals');
function toBeWithinRange(actual, floor, ceiling) {
if (typeof actual !== 'number' || typeof floor !== 'number' || typeof ceiling !== 'number') {
throw new Error('These must be of type number!');
}
const pass = actual >= floor && actual <= ceiling;
if (pass) {
return {
message: () =>
`expected ${this.utils.printReceived(actual)} not to be within range ${this.utils.printExpected(
`${floor} - ${ceiling}`
)}`,
pass: true
};
} else {
return {
message: () =>
`expected ${this.utils.printReceived(actual)} to be within range ${this.utils.printExpected(
`${floor} - ${ceiling}`
)}`,
pass: false
};
}
}
expect.extend({
toBeWithinRange
});