install(now) { const currentTime = now || new Date(); this._clock = lolex.install({ now: currentTime, shouldAdvanceTime: true, }); return this._clock; }
tap.test('fetchExistingLabels(): cache expires after one hour', async (t) => { const owner = 'nodejs' const repo = 'node2' const clock = lolex.install() // Test passes if nock is only called once, no other checks to run const scope = nock('https://api.github.com') .filteringPath(ignoreQueryParams) .get(`/repos/${owner}/${repo}/labels`) .twice() // should be called twice .reply(200, []) t.tearDown(() => { clock.uninstall() }) await nodeRepo._fetchExistingLabels({ owner, repo, logger }) // fetch labels again after 1 hour and 1 minute clock.tick(1000 * 60 * 61) await nodeRepo._fetchExistingLabels({ owner, repo, logger }) scope.done() })
suite('sending process', () => { beforeEach(() => { clock = lolex.install(Date.now()); });
suite('message handler', () => { beforeEach(() => { clock = lolex.install(Date.now()); });