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
+27 -27
View File
@@ -2,24 +2,24 @@ describe('toHaveSize', function() {
'use strict';
it('passes for an array whose length matches', function() {
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare([1, 2], 2);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare([1, 2], 2);
expect(result.pass).toBe(true);
});
it('fails for an array whose length does not match', function() {
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare([1, 2, 3], 2);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare([1, 2, 3], 2);
expect(result.pass).toBe(false);
});
it('informs about the size of an array whose length does not match', function() {
const matcher = privateUnderTest.matchers.toHaveSize({
pp: privateUnderTest.makePrettyPrinter()
}),
result = matcher.compare([1, 2, 3], 2);
pp: privateUnderTest.makePrettyPrinter()
});
const result = matcher.compare([1, 2, 3], 2);
expect(result.message()).toEqual(
'Expected [ 1, 2, 3 ] with size 3 to have size 2.'
@@ -27,43 +27,43 @@ describe('toHaveSize', function() {
});
it('passes for an object with the proper number of keys', function() {
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare({ a: 1, b: 2 }, 2);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare({ a: 1, b: 2 }, 2);
expect(result.pass).toBe(true);
});
it('fails for an object with a different number of keys', function() {
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare({ a: 1, b: 2 }, 1);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare({ a: 1, b: 2 }, 1);
expect(result.pass).toBe(false);
});
it('passes for an object with an explicit `length` property that matches', function() {
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare({ a: 1, b: 2, length: 5 }, 5);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare({ a: 1, b: 2, length: 5 }, 5);
expect(result.pass).toBe(true);
});
it('fails for an object with an explicit `length` property that does not match', function() {
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare({ a: 1, b: 2, length: 5 }, 1);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare({ a: 1, b: 2, length: 5 }, 1);
expect(result.pass).toBe(false);
});
it('passes for a string whose length matches', function() {
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare('ab', 2);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare('ab', 2);
expect(result.pass).toBe(true);
});
it('fails for a string whose length does not match', function() {
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare('abc', 2);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare('abc', 2);
expect(result.pass).toBe(false);
});
@@ -73,8 +73,8 @@ describe('toHaveSize', function() {
map.set('a', 1);
map.set('b', 2);
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare(map, 2);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare(map, 2);
expect(result.pass).toBe(true);
});
@@ -84,8 +84,8 @@ describe('toHaveSize', function() {
map.set('a', 1);
map.set('b', 2);
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare(map, 1);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare(map, 1);
expect(result.pass).toBe(false);
});
@@ -95,8 +95,8 @@ describe('toHaveSize', function() {
set.add('a');
set.add('b');
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare(set, 2);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare(set, 2);
expect(result.pass).toBe(true);
});
@@ -106,8 +106,8 @@ describe('toHaveSize', function() {
set.add('a');
set.add('b');
const matcher = privateUnderTest.matchers.toHaveSize(),
result = matcher.compare(set, 1);
const matcher = privateUnderTest.matchers.toHaveSize();
const result = matcher.compare(set, 1);
expect(result.pass).toBe(false);
});