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,8 +1,8 @@
describe('toBeInstanceOf', function() {
describe('when expecting Number', function() {
it('passes for literal number', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(3, Number);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(3, Number);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Number not to be an instance of Number'
@@ -10,10 +10,10 @@ describe('toBeInstanceOf', function() {
});
it('passes for NaN', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf({
const matcher = jasmineUnderTest.matchers.toBeInstanceOf({
pp: jasmineUnderTest.makePrettyPrinter()
});
var result = matcher.compare(NaN, Number);
const result = matcher.compare(NaN, Number);
expect(result).toEqual({
pass: true,
message: 'Expected instance of NaN not to be an instance of Number'
@@ -21,8 +21,8 @@ describe('toBeInstanceOf', function() {
});
it('passes for Infinity', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(Infinity, Number);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(Infinity, Number);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Number not to be an instance of Number'
@@ -30,8 +30,8 @@ describe('toBeInstanceOf', function() {
});
it('fails for a non-number', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare('foo', Number);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare('foo', Number);
expect(result).toEqual({
pass: false,
message: 'Expected instance of String to be an instance of Number'
@@ -41,8 +41,8 @@ describe('toBeInstanceOf', function() {
describe('when expecting String', function() {
it('passes for a string', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare('foo', String);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare('foo', String);
expect(result).toEqual({
pass: true,
message: 'Expected instance of String not to be an instance of String'
@@ -50,8 +50,8 @@ describe('toBeInstanceOf', function() {
});
it('fails for a non-string', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare({}, String);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare({}, String);
expect(result).toEqual({
pass: false,
message: 'Expected instance of Object to be an instance of String'
@@ -61,8 +61,8 @@ describe('toBeInstanceOf', function() {
describe('when expecting Boolean', function() {
it('passes for a boolean', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(true, Boolean);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(true, Boolean);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Boolean not to be an instance of Boolean'
@@ -70,8 +70,8 @@ describe('toBeInstanceOf', function() {
});
it('fails for a non-boolean', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare('false', Boolean);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare('false', Boolean);
expect(result).toEqual({
pass: false,
message: 'Expected instance of String to be an instance of Boolean'
@@ -81,8 +81,8 @@ describe('toBeInstanceOf', function() {
describe('when expecting RegExp', function() {
it('passes for a literal regular expression', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(/foo/, RegExp);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(/foo/, RegExp);
expect(result).toEqual({
pass: true,
message: 'Expected instance of RegExp not to be an instance of RegExp'
@@ -92,10 +92,10 @@ describe('toBeInstanceOf', function() {
describe('when expecting Function', function() {
it('passes for a function', function() {
var fn = function() {};
const fn = function() {};
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(fn, Function);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(fn, Function);
expect(result).toEqual({
pass: true,
message:
@@ -104,10 +104,10 @@ describe('toBeInstanceOf', function() {
});
it('passes for an async function', function() {
var fn = eval("(async function fn() { return 'foo'; })");
const fn = eval("(async function fn() { return 'foo'; })");
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(fn, Function);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(fn, Function);
expect(result).toEqual({
pass: true,
message:
@@ -120,8 +120,8 @@ describe('toBeInstanceOf', function() {
function Animal() {}
it('passes for any object', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare({ foo: 'bar' }, Object);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare({ foo: 'bar' }, Object);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Object not to be an instance of Object'
@@ -129,8 +129,8 @@ describe('toBeInstanceOf', function() {
});
it('passes for an Error object', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(new Error('example'), Object);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(new Error('example'), Object);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Error not to be an instance of Object'
@@ -138,8 +138,8 @@ describe('toBeInstanceOf', function() {
});
it('passes for a user-defined class', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(new Animal(), Object);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(new Animal(), Object);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Animal not to be an instance of Object'
@@ -147,8 +147,8 @@ describe('toBeInstanceOf', function() {
});
it('fails for a non-object', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare('foo', Object);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare('foo', Object);
expect(result).toEqual({
pass: false,
message: 'Expected instance of String to be an instance of Object'
@@ -156,12 +156,12 @@ describe('toBeInstanceOf', function() {
});
it('passes for objects with no constructor', function() {
var object = Object.create(null);
const object = Object.create(null);
var matcher = jasmineUnderTest.matchers.toBeInstanceOf({
const matcher = jasmineUnderTest.matchers.toBeInstanceOf({
pp: jasmineUnderTest.makePrettyPrinter()
});
var result = matcher.compare(object, Object);
const result = matcher.compare(object, Object);
expect(result).toEqual({
pass: true,
message:
@@ -188,8 +188,8 @@ describe('toBeInstanceOf', function() {
Cat.prototype.constructor = Cat;
it('passes for instances of that class', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(new Animal(), Animal);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(new Animal(), Animal);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Animal not to be an instance of Animal'
@@ -197,8 +197,8 @@ describe('toBeInstanceOf', function() {
});
it('passes for instances of a subclass', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(new Cat(), Animal);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(new Cat(), Animal);
expect(result).toEqual({
pass: true,
message: 'Expected instance of Cat not to be an instance of Animal'
@@ -206,8 +206,8 @@ describe('toBeInstanceOf', function() {
});
it('does not pass for sibling classes', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
var result = matcher.compare(new Dog(), Cat);
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const result = matcher.compare(new Dog(), Cat);
expect(result).toEqual({
pass: false,
message: 'Expected instance of Dog to be an instance of Cat'
@@ -216,7 +216,7 @@ describe('toBeInstanceOf', function() {
});
it('raises an error if passed an invalid expected value', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf();
const matcher = jasmineUnderTest.matchers.toBeInstanceOf();
expect(function() {
matcher.compare({}, 'Error');
}).toThrowError(
@@ -226,7 +226,7 @@ describe('toBeInstanceOf', function() {
});
it('raises an error if missing an expected value', function() {
var matcher = jasmineUnderTest.matchers.toBeInstanceOf({
const matcher = jasmineUnderTest.matchers.toBeInstanceOf({
pp: jasmineUnderTest.makePrettyPrinter()
});
expect(function() {