Run Prettier on all files
This commit is contained in:
@@ -17,8 +17,12 @@ getJasmineRequireObj().toBePending = function(j$) {
|
||||
}
|
||||
var want = {};
|
||||
return Promise.race([actual, Promise.resolve(want)]).then(
|
||||
function(got) { return {pass: want === got}; },
|
||||
function() { return {pass: false}; }
|
||||
function(got) {
|
||||
return { pass: want === got };
|
||||
},
|
||||
function() {
|
||||
return { pass: false };
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,8 +17,12 @@ getJasmineRequireObj().toBeRejected = function(j$) {
|
||||
throw new Error('Expected toBeRejected to be called on a promise.');
|
||||
}
|
||||
return actual.then(
|
||||
function() { return {pass: false}; },
|
||||
function() { return {pass: true}; }
|
||||
function() {
|
||||
return { pass: false };
|
||||
},
|
||||
function() {
|
||||
return { pass: true };
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,35 +15,44 @@ getJasmineRequireObj().toBeRejectedWith = function(j$) {
|
||||
return {
|
||||
compare: function(actualPromise, expectedValue) {
|
||||
if (!j$.isPromiseLike(actualPromise)) {
|
||||
throw new Error('Expected toBeRejectedWith to be called on a promise.');
|
||||
throw new Error(
|
||||
'Expected toBeRejectedWith to be called on a promise.'
|
||||
);
|
||||
}
|
||||
|
||||
function prefix(passed) {
|
||||
return 'Expected a promise ' +
|
||||
return (
|
||||
'Expected a promise ' +
|
||||
(passed ? 'not ' : '') +
|
||||
'to be rejected with ' + matchersUtil.pp(expectedValue);
|
||||
'to be rejected with ' +
|
||||
matchersUtil.pp(expectedValue)
|
||||
);
|
||||
}
|
||||
|
||||
return actualPromise.then(
|
||||
function() {
|
||||
return {
|
||||
pass: false,
|
||||
message: prefix(false) + ' but it was resolved.'
|
||||
};
|
||||
},
|
||||
function(actualValue) {
|
||||
if (matchersUtil.equals(actualValue, expectedValue)) {
|
||||
return {
|
||||
pass: true,
|
||||
message: prefix(true) + '.'
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
pass: false,
|
||||
message: prefix(false) + ' but it was rejected with ' + matchersUtil.pp(actualValue) + '.'
|
||||
message: prefix(false) + ' but it was resolved.'
|
||||
};
|
||||
},
|
||||
function(actualValue) {
|
||||
if (matchersUtil.equals(actualValue, expectedValue)) {
|
||||
return {
|
||||
pass: true,
|
||||
message: prefix(true) + '.'
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
pass: false,
|
||||
message:
|
||||
prefix(false) +
|
||||
' but it was rejected with ' +
|
||||
matchersUtil.pp(actualValue) +
|
||||
'.'
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,7 +18,9 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
||||
return {
|
||||
compare: function(actualPromise, arg1, arg2) {
|
||||
if (!j$.isPromiseLike(actualPromise)) {
|
||||
throw new Error('Expected toBeRejectedWithError to be called on a promise.');
|
||||
throw new Error(
|
||||
'Expected toBeRejectedWithError to be called on a promise.'
|
||||
);
|
||||
}
|
||||
|
||||
var expected = getExpectedFromArgs(arg1, arg2, matchersUtil);
|
||||
@@ -30,7 +32,9 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
||||
message: 'Expected a promise to be rejected but it was resolved.'
|
||||
};
|
||||
},
|
||||
function(actualValue) { return matchError(actualValue, expected, matchersUtil); }
|
||||
function(actualValue) {
|
||||
return matchError(actualValue, expected, matchersUtil);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -42,16 +46,25 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
||||
}
|
||||
|
||||
if (!(actual instanceof expected.error)) {
|
||||
return fail(expected, 'rejected with type ' + j$.fnNameFor(actual.constructor));
|
||||
return fail(
|
||||
expected,
|
||||
'rejected with type ' + j$.fnNameFor(actual.constructor)
|
||||
);
|
||||
}
|
||||
|
||||
var actualMessage = actual.message;
|
||||
|
||||
if (actualMessage === expected.message || typeof expected.message === 'undefined') {
|
||||
if (
|
||||
actualMessage === expected.message ||
|
||||
typeof expected.message === 'undefined'
|
||||
) {
|
||||
return pass(expected);
|
||||
}
|
||||
|
||||
if (expected.message instanceof RegExp && expected.message.test(actualMessage)) {
|
||||
if (
|
||||
expected.message instanceof RegExp &&
|
||||
expected.message.test(actualMessage)
|
||||
) {
|
||||
return pass(expected);
|
||||
}
|
||||
|
||||
@@ -61,18 +74,25 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
||||
function pass(expected) {
|
||||
return {
|
||||
pass: true,
|
||||
message: 'Expected a promise not to be rejected with ' + expected.printValue + ', but it was.'
|
||||
message:
|
||||
'Expected a promise not to be rejected with ' +
|
||||
expected.printValue +
|
||||
', but it was.'
|
||||
};
|
||||
}
|
||||
|
||||
function fail(expected, message) {
|
||||
return {
|
||||
pass: false,
|
||||
message: 'Expected a promise to be rejected with ' + expected.printValue + ' but it was ' + message + '.'
|
||||
message:
|
||||
'Expected a promise to be rejected with ' +
|
||||
expected.printValue +
|
||||
' but it was ' +
|
||||
message +
|
||||
'.'
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function getExpectedFromArgs(arg1, arg2, matchersUtil) {
|
||||
var error, message;
|
||||
|
||||
@@ -87,11 +107,16 @@ getJasmineRequireObj().toBeRejectedWithError = function(j$) {
|
||||
return {
|
||||
error: error,
|
||||
message: message,
|
||||
printValue: j$.fnNameFor(error) + (typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message))
|
||||
printValue:
|
||||
j$.fnNameFor(error) +
|
||||
(typeof message === 'undefined' ? '' : ': ' + matchersUtil.pp(message))
|
||||
};
|
||||
}
|
||||
|
||||
function isErrorConstructor(value) {
|
||||
return typeof value === 'function' && (value === Error || j$.isError_(value.prototype));
|
||||
return (
|
||||
typeof value === 'function' &&
|
||||
(value === Error || j$.isError_(value.prototype))
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,8 +18,12 @@ getJasmineRequireObj().toBeResolved = function(j$) {
|
||||
}
|
||||
|
||||
return actual.then(
|
||||
function() { return {pass: true}; },
|
||||
function() { return {pass: false}; }
|
||||
function() {
|
||||
return { pass: true };
|
||||
},
|
||||
function() {
|
||||
return { pass: false };
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,9 +19,12 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
|
||||
}
|
||||
|
||||
function prefix(passed) {
|
||||
return 'Expected a promise ' +
|
||||
return (
|
||||
'Expected a promise ' +
|
||||
(passed ? 'not ' : '') +
|
||||
'to be resolved to ' + matchersUtil.pp(expectedValue);
|
||||
'to be resolved to ' +
|
||||
matchersUtil.pp(expectedValue)
|
||||
);
|
||||
}
|
||||
|
||||
return actualPromise.then(
|
||||
@@ -34,7 +37,11 @@ getJasmineRequireObj().toBeResolvedTo = function(j$) {
|
||||
} else {
|
||||
return {
|
||||
pass: false,
|
||||
message: prefix(false) + ' but it was resolved to ' + matchersUtil.pp(actualValue) + '.'
|
||||
message:
|
||||
prefix(false) +
|
||||
' but it was resolved to ' +
|
||||
matchersUtil.pp(actualValue) +
|
||||
'.'
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user