Run Prettier on all files
This commit is contained in:
@@ -1,174 +1,253 @@
|
||||
/* eslint-disable compat/compat */
|
||||
describe('#toBeRejectedWithError', function () {
|
||||
it('passes when Error type matches', function () {
|
||||
describe('#toBeRejectedWithError', function() {
|
||||
it('passes when Error type matches', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new TypeError('foo'));
|
||||
|
||||
return matcher.compare(actual, TypeError).then(function (result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
pass: true,
|
||||
message: 'Expected a promise not to be rejected with TypeError, but it was.'
|
||||
}));
|
||||
return matcher.compare(actual, TypeError).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
jasmine.objectContaining({
|
||||
pass: true,
|
||||
message:
|
||||
'Expected a promise not to be rejected with TypeError, but it was.'
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('passes when Error type and message matches', function () {
|
||||
it('passes when Error type and message matches', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new TypeError('foo'));
|
||||
|
||||
return matcher.compare(actual, TypeError, 'foo').then(function (result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
pass: true,
|
||||
message: 'Expected a promise not to be rejected with TypeError: \'foo\', but it was.'
|
||||
}));
|
||||
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
jasmine.objectContaining({
|
||||
pass: true,
|
||||
message:
|
||||
"Expected a promise not to be rejected with TypeError: 'foo', but it was."
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('passes when Error matches and is exactly Error', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error());
|
||||
|
||||
return matcher.compare(actual, Error).then(function (result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
pass: true,
|
||||
message: 'Expected a promise not to be rejected with Error, but it was.'
|
||||
}));
|
||||
return matcher.compare(actual, Error).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
jasmine.objectContaining({
|
||||
pass: true,
|
||||
message:
|
||||
'Expected a promise not to be rejected with Error, but it was.'
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('passes when Error message matches a string', function () {
|
||||
it('passes when Error message matches a string', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, 'foo').then(function (result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
pass: true,
|
||||
message: 'Expected a promise not to be rejected with Error: \'foo\', but it was.'
|
||||
}));
|
||||
return matcher.compare(actual, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
jasmine.objectContaining({
|
||||
pass: true,
|
||||
message:
|
||||
"Expected a promise not to be rejected with Error: 'foo', but it was."
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('passes when Error message matches a RegExp', function () {
|
||||
it('passes when Error message matches a RegExp', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, /foo/).then(function (result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
pass: true,
|
||||
message: 'Expected a promise not to be rejected with Error: /foo/, but it was.'
|
||||
}));
|
||||
return matcher.compare(actual, /foo/).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
jasmine.objectContaining({
|
||||
pass: true,
|
||||
message:
|
||||
'Expected a promise not to be rejected with Error: /foo/, but it was.'
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('passes when Error message is empty', function () {
|
||||
it('passes when Error message is empty', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error());
|
||||
|
||||
return matcher.compare(actual, '').then(function (result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
pass: true,
|
||||
message: 'Expected a promise not to be rejected with Error: \'\', but it was.'
|
||||
}));
|
||||
return matcher.compare(actual, '').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
jasmine.objectContaining({
|
||||
pass: true,
|
||||
message:
|
||||
"Expected a promise not to be rejected with Error: '', but it was."
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('passes when no arguments', function () {
|
||||
it('passes when no arguments', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error());
|
||||
|
||||
return matcher.compare(actual, void 0).then(function (result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
pass: true,
|
||||
message: 'Expected a promise not to be rejected with Error, but it was.'
|
||||
}));
|
||||
return matcher.compare(actual, void 0).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
jasmine.objectContaining({
|
||||
pass: true,
|
||||
message:
|
||||
'Expected a promise not to be rejected with Error, but it was.'
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('fails when resolved', function () {
|
||||
it('fails when resolved', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.resolve(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, 'foo').then(function (result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
pass: false,
|
||||
message: 'Expected a promise to be rejected but it was resolved.'
|
||||
}));
|
||||
return matcher.compare(actual, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
jasmine.objectContaining({
|
||||
pass: false,
|
||||
message: 'Expected a promise to be rejected but it was resolved.'
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('fails when rejected with non Error type', function () {
|
||||
it('fails when rejected with non Error type', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject('foo');
|
||||
|
||||
return matcher.compare(actual, 'foo').then(function (result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
pass: false,
|
||||
message: 'Expected a promise to be rejected with Error: \'foo\' but it was rejected with \'foo\'.'
|
||||
}));
|
||||
return matcher.compare(actual, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
jasmine.objectContaining({
|
||||
pass: false,
|
||||
message:
|
||||
"Expected a promise to be rejected with Error: 'foo' but it was rejected with 'foo'."
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('fails when Error type mismatches', function () {
|
||||
it('fails when Error type mismatches', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, TypeError, 'foo').then(function (result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
pass: false,
|
||||
message: 'Expected a promise to be rejected with TypeError: \'foo\' but it was rejected with type Error.'
|
||||
}));
|
||||
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
jasmine.objectContaining({
|
||||
pass: false,
|
||||
message:
|
||||
"Expected a promise to be rejected with TypeError: 'foo' but it was rejected with type Error."
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('fails when Error message mismatches', function () {
|
||||
it('fails when Error message mismatches', function() {
|
||||
jasmine.getEnv().requirePromises();
|
||||
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, 'bar').then(function (result) {
|
||||
expect(result).toEqual(jasmine.objectContaining({
|
||||
pass: false,
|
||||
message: 'Expected a promise to be rejected with Error: \'bar\' but it was rejected with Error: foo.'
|
||||
}));
|
||||
return matcher.compare(actual, 'bar').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
jasmine.objectContaining({
|
||||
pass: false,
|
||||
message:
|
||||
"Expected a promise to be rejected with Error: 'bar' but it was rejected with Error: foo."
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it('fails if actual is not a promise', function() {
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({pp: jasmineUnderTest.makePrettyPrinter()}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(matchersUtil),
|
||||
var matchersUtil = new jasmineUnderTest.MatchersUtil({
|
||||
pp: jasmineUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = jasmineUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = 'not a promise';
|
||||
|
||||
function f() {
|
||||
|
||||
Reference in New Issue
Block a user