Also show tip for .not cases

This commit is contained in:
Gregg Van Hove
2018-10-22 10:57:16 -07:00
parent 7cbedcdda7
commit 3c47e71619
2 changed files with 38 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().toBe = function($j) {
getJasmineRequireObj().toBe = function(j$) {
/**
* {@link expect} the actual value to be `===` to the expected value.
* @function
@@ -7,16 +7,20 @@ getJasmineRequireObj().toBe = function($j) {
* @example
* expect(thing).toBe(realThing);
*/
function toBe() {
function toBe(util) {
var tip = ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
return {
compare: function(actual, expected) {
var customMessage = 'Expected ' + $j.pp(expected) + ' to be ' + $j.pp(actual) + '. Tip: To check for deep equality, use .toEqual() instead of .toBe().';
return {
var result = {
pass: actual === expected,
message: typeof expected === 'object' ? customMessage : undefined,
};
if (typeof expected === 'object') {
result.message = util.buildFailureMessage('toBe', result.pass, actual, expected) + tip;
}
return result;
}
};
}