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

@@ -1,12 +1,14 @@
describe('toHaveBeenCalledWith', function() {
it('passes when the actual was called with matching parameters', function() {
const matchersUtil = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new privateUnderTest.Spy('called-spy');
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
matchersUtil
);
const calledSpy = new privateUnderTest.Spy('called-spy');
calledSpy('a', 'b');
const result = matcher.compare(calledSpy, 'a', 'b');
@@ -19,15 +21,17 @@ describe('toHaveBeenCalledWith', function() {
it('supports custom equality testers', function() {
const customEqualityTesters = [
function() {
return true;
}
],
matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: customEqualityTesters
}),
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new privateUnderTest.Spy('called-spy');
function() {
return true;
}
];
const matchersUtil = new privateUnderTest.MatchersUtil({
customTesters: customEqualityTesters
});
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
matchersUtil
);
const calledSpy = new privateUnderTest.Spy('called-spy');
calledSpy('a', 'b');
const result = matcher.compare(calledSpy, 'a', 'b');
@@ -36,13 +40,13 @@ describe('toHaveBeenCalledWith', function() {
it('fails when the actual was not called', function() {
const matchersUtil = {
contains: jasmine
.createSpy('delegated-contains')
.and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
uncalledSpy = new privateUnderTest.Spy('uncalled spy');
contains: jasmine.createSpy('delegated-contains').and.returnValue(false),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
matchersUtil
);
const uncalledSpy = new privateUnderTest.Spy('uncalled spy');
const result = matcher.compare(uncalledSpy);
expect(result.pass).toBe(false);
@@ -53,10 +57,12 @@ describe('toHaveBeenCalledWith', function() {
it('fails when the actual was called with different parameters', function() {
const matchersUtil = new privateUnderTest.MatchersUtil({
pp: privateUnderTest.makePrettyPrinter()
}),
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new privateUnderTest.Spy('called spy');
pp: privateUnderTest.makePrettyPrinter()
});
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
matchersUtil
);
const calledSpy = new privateUnderTest.Spy('called spy');
calledSpy('a');
calledSpy('c', 'd');
@@ -85,9 +91,9 @@ describe('toHaveBeenCalledWith', function() {
it('throws an exception when the actual is not a spy', function() {
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith({
pp: privateUnderTest.makePrettyPrinter()
}),
fn = function() {};
pp: privateUnderTest.makePrettyPrinter()
});
const fn = function() {};
expect(function() {
matcher.compare(fn);
@@ -96,12 +102,14 @@ describe('toHaveBeenCalledWith', function() {
it('set the correct calls as verified when passing', function() {
const matchersUtil = {
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
},
matcher = privateUnderTest.matchers.toHaveBeenCalledWith(matchersUtil),
calledSpy = new privateUnderTest.Spy('called-spy');
contains: jasmine.createSpy('delegated-contains').and.returnValue(true),
equals: jasmine.createSpy('delegated-equals').and.returnValue(true),
pp: privateUnderTest.makePrettyPrinter()
};
const matcher = privateUnderTest.matchers.toHaveBeenCalledWith(
matchersUtil
);
const calledSpy = new privateUnderTest.Spy('called-spy');
calledSpy('a', 'b');
matcher.compare(calledSpy, 'a', 'b');