Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const assertMessage = (assertionName, message, received, expected) =>
`${matcherHint(`${assertionName}`, 'received', '')} \n${message}: ` +
`${printExpected(expected)} \nReceived: ${printReceived(received)}`
? () =>
`${matcherHint('.not.toHaveReactProps', node.toString())}\n\n` +
`Expected the React element:\n ${receivedColor(node.toString())}\n` +
`Not to have props:\n ${printExpected(props)}\n` +
`Received:\n ${printReceived(node.props)}\n`
: () => {
? () =>
`${matcherHint('.not.toHavePerformedGraphQLOperation')}\n\n` +
`Expected not to have performed GraphQL ${type}:\n ${expectedColor(
name,
)}\n${
variables
? `With variables matching:\n ${printExpected(variables)}\n`
: ''
}` +
`But ${foundByVariables.length} matching ${
foundByVariables.length === 1 ? 'operation was' : 'operations were'
} found.\n`
: () =>
message: () => {
return [
matcherHint(`${this.isNot ? '.not' : ''}.toHaveFocus`, 'element', ''),
'',
'Expected',
` ${printExpected(element)}`,
'Received:',
` ${printReceived(element.ownerDocument.activeElement)}`,
].join('\n')
},
}
) => () =>
`${matcherHint('.toTransformNode')}\n\n${shouldChange}`
? 'Expected the node to be transformed to:\n' +
`${printExpected(expected.toString())}\n` +
`Position: { from: ${selectionFor(expected).from}, to: ${selectionFor(expected).to} }\n\n` +
'Received:\n' +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`
: 'Expected the node not to be changed from:\n' +
`${printExpected(expected.toString())}\n` +
`Position: { from: ${selectionFor(expected).from} to: ${selectionFor(expected).to} }\n\n` +
'Received:\n' +
`${printReceived(actual.toString())}\n` +
`Position: { from: ${selectionFor(actual).from}, to: ${selectionFor(actual).to} }\n\n`;
message: () =>
message(
matcherHint(`.${matcherName}`, `Function ${fn.name}`),
printExpected(result.permutation),
chalk.red(result.error.stack)
),
notMessage: () =>
message: () => pass ? '' :
`${matcherHint('.toBeTypeOf')}\n` +
`\n` +
`Received:\n` +
` ${printReceived(getType(received))}\n` +
`Expected:\n` +
` ${printExpected(getType(expected))}\n` +
`For value:\n` +
JSON.stringify(received, null, 2),
pass,
: () =>
`${matcherHint('.toBeFormated', formatedReceived)}\n\n` +
`Expected:\n ${receivedColor(formatedReceived)}\n` +
`To be equal to:\n ${printExpected(formatedExpected)}\n`;
trimmedStack
);
}
if (operatorName === 'fail') {
return (
buildHintString(assertMatcherHint(operator, operatorName, expected)) +
chalk.reset(hasCustomMessage ? 'Message:\n ' + message : '') +
trimmedStack
);
}
return (
buildHintString(assertMatcherHint(operator, operatorName, expected)) +
chalk.reset(`Expected value ${operatorMessage(operator)}`) +
` ${printExpected(expected)}\n` +
chalk.reset(`Received:\n`) +
` ${printReceived(actual)}` +
chalk.reset(hasCustomMessage ? '\n\nMessage:\n ' + message : '') +
(diffString ? `\n\nDifference:\n\n${diffString}` : '') +
trimmedStack
);
}
const passMessage = (object, entries) => () =>
matcherHint('.not.toContainAnyEntries') +
'\n\n' +
'Expected object to not contain any of the provided entries:\n' +
` ${printExpected(entries)}\n` +
'Received:\n' +
` ${printReceived(object)}`;