Skip to content

Commit d29c001

Browse files
committed
Add getRandomTime util
1 parent 72812aa commit d29c001

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test-utils.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
export function getRandomTime() {
2+
return Math.random() * 100;
3+
}
4+
15
export function duplicate(x) {
26
return x * 2;
37
}
@@ -6,7 +10,7 @@ export function duplicateInRandomTime(x) {
610
return new Promise(
711
(resolve) => setTimeout(() => {
812
resolve(x * 2);
9-
}, Math.random() * 100),
13+
}, getRandomTime()),
1014
);
1115
}
1216

@@ -18,7 +22,7 @@ export function largerThanTwoInRandomTime(x) {
1822
return new Promise(
1923
(resolve) => setTimeout(() => {
2024
resolve(x > 2);
21-
}, Math.random() * 100),
25+
}, getRandomTime()),
2226
);
2327
}
2428

@@ -30,7 +34,7 @@ export function largerThanOneHundredInRandomTime(x) {
3034
return new Promise(
3135
(resolve) => setTimeout(() => {
3236
resolve(x > 100);
33-
}, Math.random() * 100),
37+
}, getRandomTime()),
3438
);
3539
}
3640

0 commit comments

Comments
 (0)