Skip to content

Commit 1717971

Browse files
committed
Remove yet more unnecessary
1 parent 507257d commit 1717971

3 files changed

Lines changed: 6 additions & 26 deletions

File tree

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint": "yarn prettier:check && eslint --ext .js,.jsx,.ts,.tsx,.graphql .",
1111
"lint:fix": "eslint --ext .js,.jsx,.ts,.tsx,.graphql . --fix; prettier --ignore-path .eslintignore --write '**/*.{js,jsx,ts,tsx,graphql,md,json}'",
1212
"prettier:check": "prettier --ignore-path .eslintignore --check '**/*.{js,jsx,ts,tsx,graphql,md,json}'",
13-
"test": "yarn prepack && jest && depcheck --ignores @types/*,@sinonjs/*,@tsconfig/*",
13+
"test": "yarn prepack && jest && depcheck --ignores @types/*,@tsconfig/*",
1414
"preversion": "grep '^### Pending' RELEASE_NOTES.md && echo \"⚠️ Cannot publish with 'Pending' in RELEASE_NOTES ⚠️\" && exit 1 || true"
1515
},
1616
"repository": {
@@ -45,7 +45,6 @@
4545
"@tsconfig/node20": "^20.1.9",
4646
"@types/jest": "^30.0.0",
4747
"@types/node": "^14.14.21",
48-
"@types/sinonjs__fake-timers": "^15.0.1",
4948
"@typescript-eslint/eslint-plugin": "^4.13.0",
5049
"@typescript-eslint/parser": "^4.13.0",
5150
"depcheck": "^1.3.1",

src/index.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as assert from "assert";
22
import * as util from "util";
3-
import type { Clock } from "@sinonjs/fake-timers";
43

54
// Grab the setTimeout from global before jest overwrites it with useFakeTimers
65
const setTimeoutBypassingFakes = global.setTimeout;
@@ -127,18 +126,15 @@ export function setupFakeTimers() {
127126
)}'`,
128127
);
129128

130-
const clock = (Date as any).clock;
131-
assertSinonJsClock(clock);
132-
133-
if (targetTimestamp < clock.now) {
134-
clock.setSystemTime(targetTimestamp);
129+
if (targetTimestamp < Date.now()) {
130+
jest.setSystemTime(targetTimestamp);
135131
} else {
136-
while (clock.now + increment < targetTimestamp) {
132+
while (Date.now() + increment < targetTimestamp) {
137133
jest.advanceTimersByTime(increment);
138134
await aFewRunLoops();
139135
}
140-
if (clock.now < targetTimestamp) {
141-
jest.advanceTimersByTime(targetTimestamp - clock.now);
136+
if (Date.now() < targetTimestamp) {
137+
jest.advanceTimersByTime(targetTimestamp - Date.now());
142138
await aFewRunLoops();
143139
}
144140
}
@@ -149,16 +145,6 @@ export function setupFakeTimers() {
149145
return { setTime, realNow };
150146
}
151147

152-
function assertSinonJsClock(clock: any): asserts clock is Clock {
153-
if (
154-
!clock ||
155-
typeof clock.now !== "number" ||
156-
typeof clock.setSystemTime !== "function"
157-
) {
158-
throw new Error(`Expected sinonjs clock!`);
159-
}
160-
}
161-
162148
/** One second in milliseconds */
163149
export const SECOND = 1000;
164150
/** One minute in milliseconds */

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -852,11 +852,6 @@
852852
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
853853
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==
854854

855-
"@types/sinonjs__fake-timers@^15.0.1":
856-
version "15.0.1"
857-
resolved "https://registry.yarnpkg.com/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-15.0.1.tgz#49f731d9453f52d64dd79f5a5626c1cf1b81bea4"
858-
integrity sha512-Ko2tjWJq8oozHzHV+reuvS5KYIRAokHnGbDwGh/J64LntgpbuylF74ipEL24HCyRjf9FOlBiBHWBR1RlVKsI1w==
859-
860855
"@types/stack-utils@^2.0.3":
861856
version "2.0.3"
862857
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8"

0 commit comments

Comments
 (0)