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:
@@ -1,7 +1,7 @@
|
||||
describe('FakeDate', function() {
|
||||
it('does not fail if no global date is found', function() {
|
||||
const fakeGlobal = {},
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const fakeGlobal = {};
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
expect(function() {
|
||||
mockDate.install();
|
||||
@@ -12,14 +12,14 @@ describe('FakeDate', function() {
|
||||
|
||||
it('replaces the global Date when it is installed', function() {
|
||||
const globalDate = jasmine
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {}
|
||||
};
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
expect(fakeGlobal.Date).toEqual(globalDate);
|
||||
mockDate.install();
|
||||
@@ -29,14 +29,14 @@ describe('FakeDate', function() {
|
||||
|
||||
it('replaces the global Date on uninstall', function() {
|
||||
const globalDate = jasmine
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {}
|
||||
};
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
mockDate.uninstall();
|
||||
@@ -46,16 +46,16 @@ describe('FakeDate', function() {
|
||||
|
||||
it('takes the current time as the base when installing without parameters', function() {
|
||||
const globalDate = jasmine
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -65,9 +65,9 @@ describe('FakeDate', function() {
|
||||
});
|
||||
|
||||
it('can accept a date as time base when installing', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal),
|
||||
baseDate = new Date();
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const baseDate = new Date();
|
||||
|
||||
spyOn(baseDate, 'getTime').and.returnValue(123);
|
||||
mockDate.install(baseDate);
|
||||
@@ -76,8 +76,8 @@ describe('FakeDate', function() {
|
||||
});
|
||||
|
||||
it('makes real dates', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
expect(new fakeGlobal.Date()).toEqual(jasmine.any(Date));
|
||||
@@ -86,15 +86,15 @@ describe('FakeDate', function() {
|
||||
|
||||
it('fakes current time when using Date.now()', function() {
|
||||
const globalDate = jasmine
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate };
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
|
||||
globalDate.now = function() {};
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
@@ -106,15 +106,15 @@ describe('FakeDate', function() {
|
||||
|
||||
it('makes time passes using tick', function() {
|
||||
const globalDate = jasmine
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate };
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
|
||||
globalDate.now = function() {};
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
@@ -132,15 +132,15 @@ describe('FakeDate', function() {
|
||||
|
||||
it('allows to increase 0 milliseconds using tick', function() {
|
||||
const globalDate = jasmine
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
}),
|
||||
fakeGlobal = { Date: globalDate };
|
||||
.createSpy('global Date')
|
||||
.and.callFake(function() {
|
||||
return {
|
||||
getTime: function() {
|
||||
return 1000;
|
||||
}
|
||||
};
|
||||
});
|
||||
const fakeGlobal = { Date: globalDate };
|
||||
|
||||
globalDate.now = function() {};
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
@@ -155,8 +155,8 @@ describe('FakeDate', function() {
|
||||
});
|
||||
|
||||
it('allows creation of a Date in a different time than the mocked time', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -167,8 +167,8 @@ describe('FakeDate', function() {
|
||||
});
|
||||
|
||||
it("allows creation of a Date that isn't fully specified", function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -177,9 +177,9 @@ describe('FakeDate', function() {
|
||||
});
|
||||
|
||||
it('allows creation of a Date with millis', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal),
|
||||
now = new Date(2014, 3, 15).getTime();
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const now = new Date(2014, 3, 15).getTime();
|
||||
|
||||
mockDate.install();
|
||||
|
||||
@@ -188,8 +188,8 @@ describe('FakeDate', function() {
|
||||
});
|
||||
|
||||
it('copies all Date properties to the mocked date', function() {
|
||||
const fakeGlobal = { Date: Date },
|
||||
mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
const fakeGlobal = { Date: Date };
|
||||
const mockDate = new privateUnderTest.MockDate(fakeGlobal);
|
||||
|
||||
mockDate.install();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user