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


TypeScript mockdate.set函數代碼示例

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


在下文中一共展示了set函數的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: 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

示例3: 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

示例4: test

    test('should report request timeouts', async () => {
      const socket = await getConnectedSocket();

      jest.useFakeTimers();
      socket.addListener('hubs', 'hub_updated', _ => {})
        .catch(() => {});
      socket.addListener('hubs', 'hub_added', _ => {})
        .catch(() => {});

      jest.runTimersToTime(35000);

      MockDate.set(Date.now() + 35000);
      (socket as any).reportRequestTimeouts();

      expect(mockConsole.warn.mock.calls.length).toBe(2);
      
      expect(socket.getPendingRequestCount()).toBe(2);

      socket.disconnect();
      expect(socket.getPendingRequestCount()).toBe(0);
    });
開發者ID:airdcpp-web,項目名稱:airdcpp-apisocket-js,代碼行數:21,代碼來源:Socket.test.ts

示例5: beforeEach

 beforeEach(() => {
   MockDate.set('2018-07-17T16:02:33+00:00', 240);
 });
開發者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.set函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。