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:
Steve Gravrock
2026-03-10 20:02:42 -07:00
parent 03ebebf6fb
commit 434575f49d
88 changed files with 3650 additions and 3604 deletions

View File

@@ -8,10 +8,10 @@ describe('toThrowError', function() {
});
it('throws an error when the expected is not an Error, string, or RegExp', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error('foo');
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new Error('foo');
};
expect(function() {
matcher.compare(fn, 1);
@@ -19,10 +19,10 @@ describe('toThrowError', function() {
});
it('throws an error when the expected error type is not an Error', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error('foo');
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new Error('foo');
};
expect(function() {
matcher.compare(fn, void 0, 'foo');
@@ -30,10 +30,10 @@ describe('toThrowError', function() {
});
it('throws an error when the expected error message is not a string or RegExp', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error('foo');
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new Error('foo');
};
expect(function() {
matcher.compare(fn, Error, 1);
@@ -41,10 +41,10 @@ describe('toThrowError', function() {
});
it('fails if actual does not throw at all', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
return true;
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
return true;
};
const result = matcher.compare(fn);
@@ -54,11 +54,11 @@ describe('toThrowError', function() {
it('fails if thrown is not an instanceof Error', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw 4;
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw 4;
};
const result = matcher.compare(fn);
expect(result.pass).toBe(false);
@@ -104,11 +104,11 @@ describe('toThrowError', function() {
it('fails with the correct message if thrown is a falsy value', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw undefined;
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw undefined;
};
const result = matcher.compare(fn);
expect(result.pass).toBe(false);
@@ -118,10 +118,10 @@ describe('toThrowError', function() {
});
it('passes if thrown is a type of Error, but there is no expected error', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
throw new TypeError();
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new TypeError();
};
const result = matcher.compare(fn);
@@ -133,11 +133,11 @@ describe('toThrowError', function() {
it('passes if thrown is an Error and the expected is the same message', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('foo');
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw new Error('foo');
};
const result = matcher.compare(fn, 'foo');
@@ -149,11 +149,11 @@ describe('toThrowError', function() {
it('fails if thrown is an Error and the expected is not the same message', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('foo');
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw new Error('foo');
};
const result = matcher.compare(fn, 'bar');
@@ -165,11 +165,11 @@ describe('toThrowError', function() {
it('passes if thrown is an Error and the expected is a RegExp that matches the message', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('a long message');
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw new Error('a long message');
};
const result = matcher.compare(fn, /long/);
@@ -181,11 +181,11 @@ describe('toThrowError', function() {
it('fails if thrown is an Error and the expected is a RegExp that does not match the message', function() {
const matcher = privateUnderTest.matchers.toThrowError({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {
throw new Error('a long message');
};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {
throw new Error('a long message');
};
const result = matcher.compare(fn, /foo/);
@@ -196,10 +196,10 @@ describe('toThrowError', function() {
});
it('passes if thrown is an Error and the expected the same Error', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new Error();
};
const result = matcher.compare(fn, Error);
@@ -208,13 +208,13 @@ describe('toThrowError', function() {
});
it('passes if thrown is a custom error that takes arguments and the expected is the same error', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
CustomError = function CustomError(arg) {
arg.x;
},
fn = function() {
throw new CustomError({ x: 1 });
};
const matcher = privateUnderTest.matchers.toThrowError();
const CustomError = function CustomError(arg) {
arg.x;
};
const fn = function() {
throw new CustomError({ x: 1 });
};
CustomError.prototype = new Error();
@@ -227,10 +227,10 @@ describe('toThrowError', function() {
});
it('fails if thrown is an Error and the expected is a different Error', function() {
const matcher = privateUnderTest.matchers.toThrowError(),
fn = function() {
throw new Error();
};
const matcher = privateUnderTest.matchers.toThrowError();
const fn = function() {
throw new Error();
};
const result = matcher.compare(fn, TypeError);
@@ -242,13 +242,13 @@ describe('toThrowError', function() {
it('passes if thrown is a type of Error and it is equal to the expected Error and message', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
const fn = function() {
throw new TypeError('foo');
};
const result = matcher.compare(fn, TypeError, 'foo');
@@ -260,16 +260,16 @@ describe('toThrowError', function() {
it('passes if thrown is a custom error that takes arguments and it is equal to the expected custom error and message', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
CustomError = function CustomError(arg) {
this.message = arg.message;
},
fn = function() {
throw new CustomError({ message: 'foo' });
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
const CustomError = function CustomError(arg) {
this.message = arg.message;
};
const fn = function() {
throw new CustomError({ message: 'foo' });
};
CustomError.prototype = new Error();
@@ -284,13 +284,13 @@ describe('toThrowError', function() {
describe('with a string', function() {
it('fails if thrown is a type of Error and the expected is a different Error', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
const fn = function() {
throw new TypeError('foo');
};
const result = matcher.compare(fn, TypeError, 'bar');
@@ -304,13 +304,13 @@ describe('toThrowError', function() {
describe('with a regex', function() {
it('fails if thrown is a type of Error and the expected is a different Error', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
const fn = function() {
throw new TypeError('foo');
};
const result = matcher.compare(fn, TypeError, /bar/);
@@ -323,13 +323,13 @@ describe('toThrowError', function() {
it('passes if thrown is a type of Error and has the same type as the expected Error and the message matches the expected message', function() {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toThrowError(matchersUtil),
fn = function() {
throw new TypeError('foo');
};
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toThrowError(matchersUtil);
const fn = function() {
throw new TypeError('foo');
};
const result = matcher.compare(fn, TypeError, /foo/);