Use one declaration per statement
The old style of merging all of a function's variable declarations into a single statement made some sense back in the days of var, but there's no reason to keep doing it now that we use const and let.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
describe('#toBeRejectedWithError', function() {
|
||||
it('passes when Error type matches', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new TypeError('foo'));
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject(new TypeError('foo'));
|
||||
|
||||
return matcher.compare(actual, TypeError).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -21,12 +21,12 @@ describe('#toBeRejectedWithError', function() {
|
||||
|
||||
it('passes when Error type and message matches', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new TypeError('foo'));
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject(new TypeError('foo'));
|
||||
|
||||
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -41,12 +41,12 @@ describe('#toBeRejectedWithError', function() {
|
||||
|
||||
it('passes when Error matches and is exactly Error', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error());
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject(new Error());
|
||||
|
||||
return matcher.compare(actual, Error).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -61,12 +61,12 @@ describe('#toBeRejectedWithError', function() {
|
||||
|
||||
it('passes when Error message matches a string', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -81,12 +81,12 @@ describe('#toBeRejectedWithError', function() {
|
||||
|
||||
it('passes when Error message matches a RegExp', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, /foo/).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -101,12 +101,12 @@ describe('#toBeRejectedWithError', function() {
|
||||
|
||||
it('passes when Error message is empty', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error());
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject(new Error());
|
||||
|
||||
return matcher.compare(actual, '').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -121,12 +121,12 @@ describe('#toBeRejectedWithError', function() {
|
||||
|
||||
it('passes when no arguments', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error());
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject(new Error());
|
||||
|
||||
return matcher.compare(actual, void 0).then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -141,12 +141,12 @@ describe('#toBeRejectedWithError', function() {
|
||||
|
||||
it('fails when resolved', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.resolve(new Error('foo'));
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.resolve(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -160,12 +160,12 @@ describe('#toBeRejectedWithError', function() {
|
||||
|
||||
it('fails when rejected with non Error type', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject('foo');
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject('foo');
|
||||
|
||||
return matcher.compare(actual, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -180,12 +180,12 @@ describe('#toBeRejectedWithError', function() {
|
||||
|
||||
it('fails when Error type mismatches', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, TypeError, 'foo').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -200,12 +200,12 @@ describe('#toBeRejectedWithError', function() {
|
||||
|
||||
it('fails when Error message mismatches', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = Promise.reject(new Error('foo'));
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = Promise.reject(new Error('foo'));
|
||||
|
||||
return matcher.compare(actual, 'bar').then(function(result) {
|
||||
expect(result).toEqual(
|
||||
@@ -220,12 +220,12 @@ describe('#toBeRejectedWithError', function() {
|
||||
|
||||
it('fails if actual is not a promise', function() {
|
||||
const matchersUtil = new privateUnderTest.MatchersUtil({
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
}),
|
||||
matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
),
|
||||
actual = 'not a promise';
|
||||
pp: privateUnderTest.makePrettyPrinter()
|
||||
});
|
||||
const matcher = privateUnderTest.asyncMatchers.toBeRejectedWithError(
|
||||
matchersUtil
|
||||
);
|
||||
const actual = 'not a promise';
|
||||
|
||||
function f() {
|
||||
return matcher.compare(actual);
|
||||
|
||||
Reference in New Issue
Block a user