當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript mockdate.reset函數代碼示例

本文整理匯總了TypeScript中mockdate.reset函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript reset函數的具體用法?TypeScript reset怎麽用?TypeScript reset使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了reset函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

    it('generates correcty zoned recurrences when a tzid is present', () => {
      const targetZone = 'America/New_York'
      const currentLocalDate = DateTime.local(2000, 2, 6, 11, 0, 0)
      setMockDate(currentLocalDate.toJSDate())

      const set = new RRuleSet()

      set.rrule(new RRule({
        freq: RRule.YEARLY,
        count: 4,
        dtstart: DateTime.fromISO('20000101T090000').toJSDate(),
        tzid: targetZone
      }))

      set.exdate(
        DateTime.fromISO('20010101T090000').toJSDate(),
      )

      set.rdate(
        DateTime.fromISO('20020301T090000').toJSDate(),
      )     

      expect(set.all()).to.deep.equal([
        expectedDate(DateTime.fromISO('20000101T090000'), currentLocalDate, targetZone),
        expectedDate(DateTime.fromISO('20020101T090000'), currentLocalDate, targetZone),
        expectedDate(DateTime.fromISO('20020301T090000'), currentLocalDate, targetZone),
        expectedDate(DateTime.fromISO('20030101T090000'), currentLocalDate, targetZone),
      ])

      resetMockDate()
    })
開發者ID:jkbrzt,項目名稱:rrule,代碼行數:31,代碼來源:rruleset.test.ts

示例2: afterEach

  afterEach(() => {
    server.stop();
    jest.useRealTimers();
    MockDate.reset();

    mockConsole.log.mockClear();
    mockConsole.info.mockClear();
    mockConsole.warn.mockClear();
    mockConsole.error.mockClear();
  });
開發者ID:airdcpp-web,項目名稱:airdcpp-apisocket-js,代碼行數:10,代碼來源:Socket.test.ts

示例3: it

  it('returns the date in the correct zone when given', () => {
    const targetZone = 'America/New_York'
    const currentLocalDate = DateTime.local(2000, 2, 6, 1, 0, 0)
    setMockDate(currentLocalDate.toJSDate())

    const d = DateTime.fromISO('20101005T110000').toJSDate()
    const dt = new DateWithZone(d, targetZone)
    expect(dt.rezonedDate()).to.deep.equal(
      expectedDate(DateTime.fromISO('20101005T110000'), currentLocalDate, targetZone)
    )

    resetMockDate()
  })
開發者ID:jkbrzt,項目名稱:rrule,代碼行數:13,代碼來源:datewithzone.test.ts

示例4: test

test('locks out users who have not confirmed after N days if `lockoutAfter` is true', async (t) => {
  let app = new AppAcceptanceTest();
  let loginCredentials = {
    email: 'dave@example.com',
    password: '123'
  };
  await app.post('/users/auth/register', {
    data: {
      type: 'user',
      attributes: loginCredentials
    }
  });
  MockDate.set(moment().add(1, 'year').toDate());

  let { status } = await app.post('/users/auth/login', loginCredentials);
  t.is(status, 403);
  MockDate.reset();
});
開發者ID:davewasmer,項目名稱:denali-auth,代碼行數:18,代碼來源:confirmable-test.ts

示例5: afterEach

 afterEach(() => {
   MockDate.reset(0);
 });
開發者ID:CityOfBoston,項目名稱:cob-patterns,代碼行數:3,代碼來源:map-util.spec.ts

示例6: Date

import * as mockdate from 'mockdate';

mockdate.set(new Date());
mockdate.set('2017-01-05');
mockdate.set(new Date().getTime());

mockdate.set(new Date(), 0);

mockdate.reset();
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:9,代碼來源:mockdate-tests.ts


注:本文中的mockdate.reset函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。