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
+30 -28
View File
@@ -1,17 +1,17 @@
describe('toBe', function() {
it('passes with no message when actual === expected', function() {
const matchersUtil = new privateUnderTest.MatchersUtil(),
matcher = privateUnderTest.matchers.toBe(matchersUtil),
result = matcher.compare(1, 1);
const matchersUtil = new privateUnderTest.MatchersUtil();
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
const result = matcher.compare(1, 1);
expect(result.pass).toBe(true);
});
it('passes with a custom message when expected is an array', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.matchers.toBe(matchersUtil),
array = [1];
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
const array = [1];
const result = matcher.compare(array, array);
expect(result.pass).toBe(true);
@@ -22,10 +22,10 @@ describe('toBe', function() {
it('passes with a custom message when expected is an object', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.matchers.toBe(matchersUtil),
obj = { foo: 'bar' };
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
const obj = { foo: 'bar' };
const result = matcher.compare(obj, obj);
expect(result.pass).toBe(true);
@@ -35,19 +35,19 @@ describe('toBe', function() {
});
it('fails with no message when actual !== expected', function() {
const matchersUtil = new privateUnderTest.MatchersUtil(),
matcher = privateUnderTest.matchers.toBe(matchersUtil),
result = matcher.compare(1, 2);
const matchersUtil = new privateUnderTest.MatchersUtil();
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
const result = matcher.compare(1, 2);
expect(result.pass).toBe(false);
expect(result.message).toBeUndefined();
});
it('fails with a custom message when expected is an array', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.matchers.toBe(matchersUtil),
result = matcher.compare([1], [1]);
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
const result = matcher.compare([1], [1]);
expect(result.pass).toBe(false);
expect(result.message).toBe(
@@ -57,10 +57,10 @@ describe('toBe', function() {
it('fails with a custom message when expected is an object', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.matchers.toBe(matchersUtil),
result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
const result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
expect(result.pass).toBe(false);
expect(result.message).toBe(
@@ -70,12 +70,14 @@ describe('toBe', function() {
it('works with custom object formatters when expected is an object', function() {
const formatter = function(x) {
return '<' + x.foo + '>';
},
prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]),
matchersUtil = new privateUnderTest.MatchersUtil({ pp: prettyPrinter }),
matcher = privateUnderTest.matchers.toBe(matchersUtil),
result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
return '<' + x.foo + '>';
};
const prettyPrinter = privateUnderTest.makePrettyPrinter([formatter]);
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: prettyPrinter
});
const matcher = privateUnderTest.matchers.toBe(matchersUtil);
const result = matcher.compare({ foo: 'bar' }, { foo: 'bar' });
expect(result.pass).toBe(false);
expect(result.message).toBe(