11import { cacheEnabled , fetchLite , lazyCallback , promiseLimit } from "./Utils"
22
3- const TIMER_MULTIPLER = 3
3+ const TIMER_MULTIPLIER = 3
44
55describe ( "utils" , ( ) => {
66 it ( "lazy callback: immediate call" , async ( ) => {
@@ -14,18 +14,18 @@ describe("utils", () => {
1414
1515 // Must run immediately:
1616 lazy ( ( ) => {
17- expect ( Date . now ( ) - now ) . toBeLessThan ( 25 * TIMER_MULTIPLER )
17+ expect ( Date . now ( ) - now ) . toBeLessThan ( 25 * TIMER_MULTIPLIER )
1818 } )
1919
20- await new Promise ( ( resolve ) => setTimeout ( resolve , 50 * TIMER_MULTIPLER ) )
20+ await new Promise ( ( resolve ) => setTimeout ( resolve , 50 * TIMER_MULTIPLIER ) )
2121 } )
2222
2323 it ( "lazy callback: avoid first call" , async ( ) => {
2424 expect . assertions ( 1 )
2525
2626 const lazy = lazyCallback ( ( callNumber : ( ) => void ) => {
2727 callNumber ( )
28- } , 25 * TIMER_MULTIPLER )
28+ } , 25 * TIMER_MULTIPLIER )
2929
3030 const now = Date . now ( )
3131
@@ -34,27 +34,27 @@ describe("utils", () => {
3434
3535 // Must run after 25ms:
3636 lazy ( ( ) => {
37- expect ( Date . now ( ) - now ) . toBeGreaterThanOrEqual ( 25 * TIMER_MULTIPLER )
37+ expect ( Date . now ( ) - now ) . toBeGreaterThanOrEqual ( 25 * TIMER_MULTIPLIER )
3838 } )
3939
40- await new Promise ( ( resolve ) => setTimeout ( resolve , 50 * TIMER_MULTIPLER ) )
40+ await new Promise ( ( resolve ) => setTimeout ( resolve , 50 * TIMER_MULTIPLIER ) )
4141 } )
4242
4343 it ( "lazy callback: wait first call" , async ( ) => {
4444 expect . assertions ( 1 )
4545
4646 const lazy = lazyCallback ( ( callNumber : ( ) => void ) => {
4747 callNumber ( )
48- } , 25 * TIMER_MULTIPLER )
48+ } , 25 * TIMER_MULTIPLIER )
4949
5050 const now = Date . now ( )
5151
5252 // Must run after 25ms:
5353 lazy ( ( ) => {
54- expect ( Date . now ( ) - now ) . toBeGreaterThanOrEqual ( 25 * TIMER_MULTIPLER )
54+ expect ( Date . now ( ) - now ) . toBeGreaterThanOrEqual ( 25 * TIMER_MULTIPLIER )
5555 } )
5656
57- await new Promise ( ( resolve ) => setTimeout ( resolve , 50 * TIMER_MULTIPLER ) )
57+ await new Promise ( ( resolve ) => setTimeout ( resolve , 50 * TIMER_MULTIPLIER ) )
5858 } )
5959
6060 it ( "lazy callback: avoid second call" , async ( ) => {
@@ -65,13 +65,13 @@ describe("utils", () => {
6565 callNumber ( )
6666 } ,
6767 0 ,
68- 25 * TIMER_MULTIPLER
68+ 25 * TIMER_MULTIPLIER
6969 )
7070
7171 const now = Date . now ( )
7272
7373 // Must run immediately:
74- lazy ( ( ) => expect ( Date . now ( ) - now ) . toBeLessThan ( 25 * TIMER_MULTIPLER ) )
74+ lazy ( ( ) => expect ( Date . now ( ) - now ) . toBeLessThan ( 25 * TIMER_MULTIPLIER ) )
7575
7676 // Must be skipped: too fast call.
7777 lazy ( ( ) => {
@@ -82,11 +82,11 @@ describe("utils", () => {
8282 lazy ( ( ) => {
8383 const nowDiff = Date . now ( ) - now
8484
85- expect ( nowDiff ) . toBeGreaterThanOrEqual ( 25 * TIMER_MULTIPLER )
86- expect ( nowDiff ) . toBeLessThan ( 50 * TIMER_MULTIPLER )
85+ expect ( nowDiff ) . toBeGreaterThanOrEqual ( 25 * TIMER_MULTIPLIER )
86+ expect ( nowDiff ) . toBeLessThan ( 50 * TIMER_MULTIPLIER )
8787 } )
8888
89- await new Promise ( ( resolve ) => setTimeout ( resolve , 50 * TIMER_MULTIPLER ) )
89+ await new Promise ( ( resolve ) => setTimeout ( resolve , 50 * TIMER_MULTIPLIER ) )
9090 } )
9191
9292 it ( "promise limit: prevent multiple simultaneous processes" , async ( ) => {
@@ -95,7 +95,7 @@ describe("utils", () => {
9595 const processesLimit = promiseLimit ( 2 )
9696
9797 const delay = ( ) : Promise < unknown > =>
98- new Promise ( ( resolve ) => setTimeout ( resolve , 25 * TIMER_MULTIPLER ) )
98+ new Promise ( ( resolve ) => setTimeout ( resolve , 25 * TIMER_MULTIPLIER ) )
9999
100100 const now = Date . now ( )
101101
@@ -108,7 +108,7 @@ describe("utils", () => {
108108 ] )
109109
110110 // The total time should be 50ms.
111- expect ( Date . now ( ) - now ) . toBeGreaterThanOrEqual ( 50 * TIMER_MULTIPLER )
111+ expect ( Date . now ( ) - now ) . toBeGreaterThanOrEqual ( 50 * TIMER_MULTIPLIER )
112112 } )
113113
114114 it ( "promise limit: run all processes simultaneous (no limit)" , async ( ) => {
@@ -117,7 +117,7 @@ describe("utils", () => {
117117 const processesLimit = promiseLimit ( 0 )
118118
119119 const delay = ( ) : Promise < unknown > =>
120- new Promise ( ( resolve ) => setTimeout ( resolve , 25 * TIMER_MULTIPLER ) )
120+ new Promise ( ( resolve ) => setTimeout ( resolve , 25 * TIMER_MULTIPLIER ) )
121121
122122 const now = Date . now ( )
123123
@@ -129,7 +129,7 @@ describe("utils", () => {
129129 ] )
130130
131131 // The total time should be lower than 50ms.
132- expect ( Date . now ( ) - now ) . toBeLessThan ( 50 * TIMER_MULTIPLER )
132+ expect ( Date . now ( ) - now ) . toBeLessThan ( 50 * TIMER_MULTIPLIER )
133133 } )
134134
135135 it ( "cache enabled (mock function-only)" , ( ) => {
0 commit comments