Open History to see the last commit
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})