Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case with keeping the maximum past date #82

Open
alexpts opened this issue Aug 30, 2021 · 0 comments
Open

Case with keeping the maximum past date #82

alexpts opened this issue Aug 30, 2021 · 0 comments

Comments

@alexpts
Copy link

alexpts commented Aug 30, 2021

I have problem with my unit test.

Example test for reproduce problem:

const chai = require('chai');
const sinon = require('sinon');
const strftime = require('strftime');

let { expect } = chai;

let sandbox = new sinon.createSandbox();

describe('strftime test', function () {
	afterEach(function () {
		sandbox.restore();
	});

	it('test one', () => {
		sandbox.useFakeTimers(new Date(2021,8,3));
		expect(strftime('%Y-%m-%d %H:%M:%S')).to.be.eq('2021-09-03 00:00:00'); // ok
	});

	it('test second, () => {
		sandbox.useFakeTimers(new Date(2021,8,1));
		expect(strftime('%Y-%m-%d %H:%M:%S')).to.be.eq('2021-09-01 00:00:00'); // fail 
	});
})

Problem relate with save state _cachedDateTimestamp/_cachedDate.

How can I reset the state for my case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant