本文整理汇总了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()
})
示例2: afterEach
afterEach(() => {
server.stop();
jest.useRealTimers();
MockDate.reset();
mockConsole.log.mockClear();
mockConsole.info.mockClear();
mockConsole.warn.mockClear();
mockConsole.error.mockClear();
});
示例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()
})
示例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();
});
示例5: afterEach
afterEach(() => {
MockDate.reset(0);
});
示例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();