chronokinesis
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -81,3 +81,2 @@ /** | ||
FakeDate.prototype = NativeDate.prototype; | ||
FakeDate.prototype.constructor = NativeDate.constructor; | ||
@@ -84,0 +83,0 @@ FakeDate.now = function() { |
{ | ||
"name": "chronokinesis", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Module for testing time-dependent code", | ||
@@ -35,4 +35,5 @@ "author": "Pal Edman <pal.edman@outlook.com>", | ||
"lab": "^10.3.0", | ||
"lodash": "^4.11.1", | ||
"moment": "^2.12.0" | ||
} | ||
} |
'use strict'; | ||
const _ = require('lodash'); | ||
const NativeDate = Date; | ||
const expect = require('code').expect; | ||
@@ -245,2 +247,27 @@ const Lab = require('lab'); | ||
lab.test('resets Date to native Date', (done) => { | ||
expect(Date).to.equal(NativeDate); | ||
ck.freeze(); | ||
expect(Date).to.not.equal(NativeDate); | ||
ck.reset(); | ||
expect(Date).to.equal(NativeDate); | ||
expect(Date.constructor).to.equal(NativeDate.constructor); | ||
expect(Date.constructor.prototype).to.equal(NativeDate.constructor.prototype); | ||
expect(new Date()).to.be.instanceOf(NativeDate).and.not.a.function(); | ||
done(); | ||
}); | ||
lab.test('after reset in combination with lodash cloneDeep returns native Date', (done) => { | ||
let content = _.assign(_.cloneDeep({ | ||
d: new Date() | ||
})); | ||
expect(content.d).to.not.be.a.function().and.instanceOf(NativeDate); | ||
done(); | ||
}); | ||
lab.test('resets frozen time', (done) => { | ||
@@ -247,0 +274,0 @@ let dateObj = new Date(); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23949
496
5