forked from TanStack/query
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremovable.test.tsx
More file actions
32 lines (26 loc) · 810 Bytes
/
removable.test.tsx
File metadata and controls
32 lines (26 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { describe, expect, test } from 'vitest'
import { Removable } from '../removable'
class TestRemovable extends Removable {
removed = 0
optionalRemove() {
this.removed++
}
// expose protected method for testing
public _updateGcTime(v: number | undefined) {
this.updateGcTime(v)
}
}
describe('removable (windowless env)', () => {
test('defaults gcTime to 5 minutes when window is undefined', () => {
const originalWindow = (globalThis as any).window
// simulate windowless client runtime (vscode/chrome extension contexts)
;(globalThis as any).window = undefined
try {
const r = new TestRemovable()
r._updateGcTime(undefined)
expect(r.gcTime).toBe(5 * 60 * 1000)
} finally {
;(globalThis as any).window = originalWindow
}
})
})