Skip to content

Commit

Permalink
chore: update @sinonjs/fake-timers (jestjs#12956)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Jun 21, 2022
1 parent 85bd57e commit 18fe820
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/jest-fake-timers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"dependencies": {
"@jest/types": "^28.1.1",
"@sinonjs/fake-timers": "^9.1.1",
"@sinonjs/fake-timers": "^9.1.2",
"@types/node": "*",
"jest-message-util": "^28.1.1",
"jest-mock": "^28.1.1",
Expand Down
26 changes: 10 additions & 16 deletions packages/jest-fake-timers/src/__tests__/modernFakeTimers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ describe('FakeTimers', () => {
console.warn.mock.calls[0][0].split('\nStack Trace')[0],
).toMatchSnapshot();
console.warn = consoleWarn;
timers.useRealTimers();
});

it('does nothing when no timers have been scheduled', () => {
Expand Down Expand Up @@ -901,14 +902,21 @@ describe('FakeTimers', () => {
});

describe('getTimerCount', () => {
it('returns the correct count', () => {
const timers = new FakeTimers({
let timers: FakeTimers;
beforeEach(() => {
timers = new FakeTimers({
config: makeProjectConfig(),
global: globalThis,
});

timers.useFakeTimers();
});

afterEach(() => {
timers.useRealTimers();
});

it('returns the correct count', () => {
globalThis.setTimeout(() => {}, 0);
globalThis.setTimeout(() => {}, 0);
globalThis.setTimeout(() => {}, 10);
Expand All @@ -925,13 +933,6 @@ describe('FakeTimers', () => {
});

it('includes immediates and ticks', () => {
const timers = new FakeTimers({
config: makeProjectConfig(),
global: globalThis,
});

timers.useFakeTimers();

globalThis.setTimeout(() => {}, 0);
globalThis.setImmediate(() => {});
process.nextTick(() => {});
Expand All @@ -940,13 +941,6 @@ describe('FakeTimers', () => {
});

it('not includes cancelled immediates', () => {
const timers = new FakeTimers({
config: makeProjectConfig(),
global: globalThis,
});

timers.useFakeTimers();

globalThis.setImmediate(() => {});
expect(timers.getTimerCount()).toEqual(1);
timers.clearAllTimers();
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2636,7 +2636,7 @@ __metadata:
dependencies:
"@jest/test-utils": ^28.1.1
"@jest/types": ^28.1.1
"@sinonjs/fake-timers": ^9.1.1
"@sinonjs/fake-timers": ^9.1.2
"@types/node": "*"
"@types/sinonjs__fake-timers": ^8.1.2
jest-message-util: ^28.1.1
Expand Down Expand Up @@ -4478,12 +4478,12 @@ __metadata:
languageName: node
linkType: hard

"@sinonjs/fake-timers@npm:^9.1.1":
version: 9.1.1
resolution: "@sinonjs/fake-timers@npm:9.1.1"
"@sinonjs/fake-timers@npm:^9.1.2":
version: 9.1.2
resolution: "@sinonjs/fake-timers@npm:9.1.2"
dependencies:
"@sinonjs/commons": ^1.7.0
checksum: 609dc6036ae1ee0f5729fb4da194475c1a48b03233f55e573ae7b3b5f646af1c47682bca1d666ae31c0721626386f0cde4847b27ca4c2a7b5379aeddfc0f9a62
checksum: 7d3aef54e17c1073101cb64d953157c19d62a40e261a30923fa1ee337b049c5f29cc47b1f0c477880f42b5659848ba9ab897607ac8ea4acd5c30ddcfac57fca6
languageName: node
linkType: hard

Expand Down

0 comments on commit 18fe820

Please sign in to comment.