How to use mockdate - 10 common examples

To help you get started, we’ve selected a few mockdate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TheFive / osmbc / test / user / uc.user.js View on Github external
beforeEach(async function() {
    mockdate.set("2015-11-05");
    mailChecker = sinon.stub( mailReceiver.for_test_only.transporter,"sendMail")
      .callsFake(function(obj, doit) { return doit(null, {response: "t"}); })
    await testutil.clearDB();
    await userModule.createNewUser({OSMUser: "TheFive", access: "full"});
    await articleModule.createNewArticle({blog: "blog", collection: "test"});
    testutil.startServerSync();
    browser = await testutil.getNewBrowser("TheFive");
    browser.evaluate(fs.readFileSync("./node_modules/timemachine/timemachine.js","UTF8"));
  });
  afterEach(function(bddone) {
github vuikit / vuikit / tests / helpers / DateMatrix.spec.js View on Github external
it('accept no arguments', () => {
    MockDate.set(new Date(2015, 0).valueOf())
    expect(
      matrix(undefined, true).toString()
    ).toEqual(jan15.toString())
    MockDate.reset()
  })
})
github adamborowski / explorejs / packages / explorejs-tester / src / store / store.spec.js View on Github external
before(() => {
    MockDate.set(new Date());
    dateModified = getFormattedDateTime();
  });
  after(() => MockDate.reset());
github soyuka / pidusage / test / wmic.js View on Github external
test.before(() => {
  mockery.enable({
    warnOnReplace: false,
    warnOnUnregistered: false,
    useCleanCache: true
  })
  mockdate.set(new Date(1427749200000))
})
github ant-design / ant-design / tests / utils.js View on Github external
export function resetMockDate() {
  MockDate.reset();
}
github RasCarlito / axios-cache-adapter / test / spec / index.spec.js View on Github external
MockDate.set(10000000)

    const api = setup({
      baseURL: 'https://httpbin.org',
      cache: { readHeaders: true }
    })

    const response = await api.get('/cache/2345')

    assert.ok(!response.request.fromCache)

    const item = await api.cache.getItem('https://httpbin.org/cache/2345')

    assert.equal(item.expires, 12345000)

    MockDate.reset()
  })
github cofacts / rumors-api / src / graphql / mutations / __tests__ / UpdateArticleReplyStatus.js View on Github external
afterEach(() => {
    MockDate.reset();
    return unloadFixtures(fixtures);
  });
});
github poanetwork / token-wizard / src / utils / validations.spec.js View on Github external
it('should fail if startTime is previous than current time', () => {
    const values = {
      tiers: [
        {
          startTime: TIMESTAMPS.CURRENT_TIME,
          endTime: TIMESTAMPS.PLUS_5_MINUTES,
        },
        {
          startTime: TIMESTAMPS.PLUS_5_MINUTES,
          endTime: TIMESTAMPS.PLUS_10_DAYS,
        },
      ]
    }

    MockDate.set(TIMESTAMPS.PLUS_5_MINUTES)

    const validationResult = validateTierStartDate(0)(values.tiers[0].startTime, values)

    expect(validationResult).toEqual([VALIDATION_MESSAGES.DATE_IN_FUTURE])
  })

mockdate

A JavaScript mock Date object that can be used to change when "now" is.

MIT
Latest version published 4 years ago

Package Health Score

70 / 100
Full package analysis

Popular mockdate functions