Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

environmentManager.test.tsx

29 lines883 Bytes

1import { afterEach, describe, expect, it } from 'vitest'
2import { environmentManager, isServer } from '..'
3​
4describe('environmentManager', () => {
5 afterEach(() => {
6 environmentManager.setIsServer(() => isServer)
7 })
8​
9 it('should use the default isServer detection', () => {
10 expect(environmentManager.isServer()).toBe(isServer)
11 })
12​
13 it('should allow overriding isServer globally', () => {
14 environmentManager.setIsServer(() => true)
15 expect(environmentManager.isServer()).toBe(true)
16​
17 environmentManager.setIsServer(() => false)
18 expect(environmentManager.isServer()).toBe(false)
19 })
20​
21 it('should allow overriding isServer with a function', () => {
22 let server = true
23 environmentManager.setIsServer(() => server)
24 expect(environmentManager.isServer()).toBe(true)
25​
26 server = false
27 expect(environmentManager.isServer()).toBe(false)
28 })
29})