Skip to content

Case with keeping the maximum past date #82

@alexpts

Description

@alexpts

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions