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,6 +1,6 @@
describe('toThrow', function() {
it('throws an error when the actual is not a function', function() {
var matcher = jasmineUnderTest.matchers.toThrow();
const matcher = jasmineUnderTest.matchers.toThrow();
expect(function() {
matcher.compare({});
@@ -9,30 +9,28 @@ describe('toThrow', function() {
});
it('fails if actual does not throw', function() {
var matcher = jasmineUnderTest.matchers.toThrow(),
const matcher = jasmineUnderTest.matchers.toThrow(),
fn = function() {
return true;
},
result;
};
result = matcher.compare(fn);
const result = matcher.compare(fn);
expect(result.pass).toBe(false);
expect(result.message).toEqual('Expected function to throw an exception.');
});
it('passes if it throws but there is no expected', function() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},
result;
};
result = matcher.compare(fn);
const result = matcher.compare(fn);
expect(result.pass).toBe(true);
expect(result.message()).toEqual(
@@ -41,15 +39,14 @@ describe('toThrow', function() {
});
it('passes even if what is thrown is falsy', function() {
var matcher = jasmineUnderTest.matchers.toThrow({
const matcher = jasmineUnderTest.matchers.toThrow({
pp: jasmineUnderTest.makePrettyPrinter()
}),
fn = function() {
throw undefined;
},
result;
};
result = matcher.compare(fn);
const result = matcher.compare(fn);
expect(result.pass).toBe(true);
expect(result.message()).toEqual(
'Expected function not to throw, but it threw undefined.'
@@ -57,34 +54,32 @@ describe('toThrow', function() {
});
it('passes if what is thrown is equivalent to what is expected', function() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(true),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},
result;
};
result = matcher.compare(fn, 5);
const result = matcher.compare(fn, 5);
expect(result.pass).toBe(true);
expect(result.message()).toEqual('Expected function not to throw 5.');
});
it('fails if what is thrown is not equivalent to what is expected', function() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},
result;
};
result = matcher.compare(fn, 'foo');
const result = matcher.compare(fn, 'foo');
expect(result.pass).toBe(false);
expect(result.message()).toEqual(
@@ -93,17 +88,16 @@ describe('toThrow', function() {
});
it('fails if what is thrown is not equivalent to undefined', function() {
var matchersUtil = {
const matchersUtil = {
equals: jasmine.createSpy('delegated-equal').and.returnValue(false),
pp: jasmineUnderTest.makePrettyPrinter()
},
matcher = jasmineUnderTest.matchers.toThrow(matchersUtil),
fn = function() {
throw 5;
},
result;
};
result = matcher.compare(fn, void 0);
const result = matcher.compare(fn, void 0);
expect(result.pass).toBe(false);
expect(result.message()).toEqual(