Created
July 10, 2017 08:23
-
-
Save Holovin/29ff8c30ba9dd38892adafafb625843d to your computer and use it in GitHub Desktop.
Jasmine unit test mock date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jasmine.clock().install(); | |
var baseTime = new Date(2013, 9, 23); | |
jasmine.clock().mockDate(baseTime); | |
jasmine.clock().tick(50) | |
expect(new Date().getTime()).toEqual(baseTime.getTime() + 50); | |
afterEach(function () { | |
jasmine.clock().uninstall(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment