Use const/let in specs, not var

This commit is contained in:
Steve Gravrock
2022-04-16 13:41:44 -07:00
parent 482dc883eb
commit 1166d10e43
111 changed files with 2522 additions and 2675 deletions

View File

@@ -1,34 +1,31 @@
describe('Expectation', function() {
it('makes custom matchers available to this expectation', function() {
var matchers = {
const matchers = {
toFoo: function() {},
toBar: function() {}
},
expectation;
expectation = jasmineUnderTest.Expectation.factory({
customMatchers: matchers
});
expectation = jasmineUnderTest.Expectation.factory({
customMatchers: matchers
});
expect(expectation.toFoo).toBeDefined();
expect(expectation.toBar).toBeDefined();
});
it('.addCoreMatchers makes matchers available to any expectation', function() {
var coreMatchers = {
toQuux: function() {}
},
expectation;
const coreMatchers = {
toQuux: function() {}
};
jasmineUnderTest.Expectation.addCoreMatchers(coreMatchers);
expectation = jasmineUnderTest.Expectation.factory({});
const expectation = jasmineUnderTest.Expectation.factory({});
expect(expectation.toQuux).toBeDefined();
});
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
var fakeCompare = function() {
const fakeCompare = function() {
return { pass: true };
},
matcherFactory = jasmine
@@ -40,10 +37,9 @@ describe('Expectation', function() {
matchersUtil = {
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
addExpectationResult = jasmine.createSpy('addExpectationResult');
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
matchersUtil: matchersUtil,
customMatchers: matchers,
actual: 'an actual',
@@ -56,7 +52,7 @@ describe('Expectation', function() {
});
it("wraps matchers's compare functions, passing the actual and expected", function() {
var fakeCompare = jasmine
const fakeCompare = jasmine
.createSpy('fake-compare')
.and.returnValue({ pass: true }),
matchers = {
@@ -69,10 +65,9 @@ describe('Expectation', function() {
matchersUtil = {
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
addExpectationResult = jasmine.createSpy('addExpectationResult');
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
matchersUtil: matchersUtil,
customMatchers: matchers,
actual: 'an actual',
@@ -85,7 +80,7 @@ describe('Expectation', function() {
});
it('reports a passing result to the spec when the comparison passes', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -97,10 +92,9 @@ describe('Expectation', function() {
matchersUtil = {
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
addExpectationResult = jasmine.createSpy('addExpectationResult');
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
customMatchers: matchers,
matchersUtil: matchersUtil,
actual: 'an actual',
@@ -121,7 +115,7 @@ describe('Expectation', function() {
});
it('reports a failing result to the spec when the comparison fails', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -135,10 +129,9 @@ describe('Expectation', function() {
return '';
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
addExpectationResult = jasmine.createSpy('addExpectationResult');
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
customMatchers: matchers,
matchersUtil: matchersUtil,
actual: 'an actual',
@@ -159,7 +152,7 @@ describe('Expectation', function() {
});
it('reports a failing result and a custom fail message to the spec when the comparison fails', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -171,10 +164,9 @@ describe('Expectation', function() {
};
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
addExpectationResult = jasmine.createSpy('addExpectationResult');
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
actual: 'an actual',
customMatchers: matchers,
addExpectationResult: addExpectationResult
@@ -194,7 +186,7 @@ describe('Expectation', function() {
});
it('reports a failing result with a custom fail message function to the spec when the comparison fails', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -208,10 +200,9 @@ describe('Expectation', function() {
};
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
addExpectationResult = jasmine.createSpy('addExpectationResult');
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
customMatchers: matchers,
actual: 'an actual',
addExpectationResult: addExpectationResult
@@ -231,7 +222,7 @@ describe('Expectation', function() {
});
it('reports a passing result to the spec when the comparison fails for a negative expectation', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -241,10 +232,9 @@ describe('Expectation', function() {
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = 'an actual',
expectation;
actual = 'an actual';
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
customMatchers: matchers,
actual: 'an actual',
addExpectationResult: addExpectationResult
@@ -264,7 +254,7 @@ describe('Expectation', function() {
});
it('reports a failing result to the spec when the comparison passes for a negative expectation', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -279,10 +269,9 @@ describe('Expectation', function() {
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = 'an actual',
expectation;
actual = 'an actual';
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
customMatchers: matchers,
actual: 'an actual',
matchersUtil: matchersUtil,
@@ -303,7 +292,7 @@ describe('Expectation', function() {
});
it('reports a failing result and a custom fail message to the spec when the comparison passes for a negative expectation', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -316,10 +305,9 @@ describe('Expectation', function() {
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = 'an actual',
expectation;
actual = 'an actual';
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
customMatchers: matchers,
actual: 'an actual',
addExpectationResult: addExpectationResult
@@ -339,7 +327,7 @@ describe('Expectation', function() {
});
it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -352,10 +340,9 @@ describe('Expectation', function() {
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = 'an actual',
expectation;
actual = 'an actual';
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
customMatchers: matchers,
actual: 'an actual',
addExpectationResult: addExpectationResult
@@ -375,7 +362,7 @@ describe('Expectation', function() {
});
it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -391,10 +378,9 @@ describe('Expectation', function() {
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
actual = 'an actual',
expectation;
actual = 'an actual';
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
customMatchers: matchers,
actual: 'an actual',
addExpectationResult: addExpectationResult
@@ -414,8 +400,8 @@ describe('Expectation', function() {
});
it('reports a custom error message to the spec', function() {
var customError = new Error('I am a custom error');
var matchers = {
const customError = new Error('I am a custom error');
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -428,10 +414,9 @@ describe('Expectation', function() {
};
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
addExpectationResult = jasmine.createSpy('addExpectationResult');
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
actual: 'an actual',
customMatchers: matchers,
addExpectationResult: addExpectationResult
@@ -451,8 +436,8 @@ describe('Expectation', function() {
});
it("reports a custom message to the spec when a 'not' comparison fails", function() {
var customError = new Error('I am a custom error');
var matchers = {
const customError = new Error('I am a custom error');
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -465,10 +450,9 @@ describe('Expectation', function() {
};
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
addExpectationResult = jasmine.createSpy('addExpectationResult');
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
actual: 'an actual',
customMatchers: matchers,
addExpectationResult: addExpectationResult
@@ -488,8 +472,8 @@ describe('Expectation', function() {
});
it("reports a custom message func to the spec when a 'not' comparison fails", function() {
var customError = new Error('I am a custom error');
var matchers = {
const customError = new Error('I am a custom error');
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -504,10 +488,9 @@ describe('Expectation', function() {
};
}
},
addExpectationResult = jasmine.createSpy('addExpectationResult'),
expectation;
addExpectationResult = jasmine.createSpy('addExpectationResult');
expectation = jasmineUnderTest.Expectation.factory({
const expectation = jasmineUnderTest.Expectation.factory({
actual: 'an actual',
customMatchers: matchers,
addExpectationResult: addExpectationResult
@@ -528,7 +511,7 @@ describe('Expectation', function() {
describe('#withContext', function() {
it('prepends the context to the generated failure message', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -561,7 +544,7 @@ describe('Expectation', function() {
});
it('prepends the context to a custom failure message', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -588,7 +571,7 @@ describe('Expectation', function() {
});
it('indents a multiline failure message', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -602,19 +585,18 @@ describe('Expectation', function() {
customMatchers: matchers,
actual: 'an actual',
addExpectationResult: addExpectationResult
}),
actualMessage;
});
expectation.withContext('Some context').toFoo('hello');
actualMessage = addExpectationResult.calls.argsFor(0)[1].message;
const actualMessage = addExpectationResult.calls.argsFor(0)[1].message;
expect(actualMessage).toEqual(
'Some context:\n a\n multiline\n message'
);
});
it('prepends the context to a custom failure message from a function', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -646,7 +628,7 @@ describe('Expectation', function() {
});
it('works with #not', function() {
var matchers = {
const matchers = {
toFoo: function() {
return {
compare: function() {
@@ -675,8 +657,8 @@ describe('Expectation', function() {
});
it('works with #not and a custom message', function() {
var customError = new Error('I am a custom error');
var matchers = {
const customError = new Error('I am a custom error');
const matchers = {
toFoo: function() {
return {
compare: function() {