This repository was archived by the owner on May 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathcloud-environment.spec.ts
More file actions
122 lines (101 loc) · 3.71 KB
/
Copy pathcloud-environment.spec.ts
File metadata and controls
122 lines (101 loc) · 3.71 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import {
isCloudEnvironment,
getAppEnvironment,
isPreviewEnvironment,
isProductionEnvironment,
isDevelopmentEnvironment,
} from "../cloud-environment"
describe("cloud-environment", () => {
const originalEnv = process.env
beforeEach(() => {
// Reset process.env before each test
vi.resetModules()
process.env = { ...originalEnv }
})
afterAll(() => {
// Restore original process.env after all tests
process.env = originalEnv
})
describe("isCloudEnvironment", () => {
it("should return true when ROO_CODE_IPC_SOCKET_PATH is set", () => {
process.env.ROO_CODE_IPC_SOCKET_PATH = "/tmp/test.sock"
expect(isCloudEnvironment()).toBe(true)
})
it("should return false when ROO_CODE_IPC_SOCKET_PATH is not set", () => {
delete process.env.ROO_CODE_IPC_SOCKET_PATH
expect(isCloudEnvironment()).toBe(false)
})
it("should return false when ROO_CODE_IPC_SOCKET_PATH is undefined", () => {
process.env.ROO_CODE_IPC_SOCKET_PATH = undefined as any
expect(isCloudEnvironment()).toBe(false)
})
})
describe("getAppEnvironment", () => {
it('should return "development" when ROO_CODE_APP_ENV is development', () => {
process.env.ROO_CODE_APP_ENV = "development"
expect(getAppEnvironment()).toBe("development")
})
it('should return "preview" when ROO_CODE_APP_ENV is preview', () => {
process.env.ROO_CODE_APP_ENV = "preview"
expect(getAppEnvironment()).toBe("preview")
})
it('should return "production" when ROO_CODE_APP_ENV is production', () => {
process.env.ROO_CODE_APP_ENV = "production"
expect(getAppEnvironment()).toBe("production")
})
it("should return undefined when ROO_CODE_APP_ENV is not set", () => {
delete process.env.ROO_CODE_APP_ENV
expect(getAppEnvironment()).toBeUndefined()
})
it("should return undefined when ROO_CODE_APP_ENV has invalid value", () => {
process.env.ROO_CODE_APP_ENV = "invalid"
expect(getAppEnvironment()).toBeUndefined()
})
})
describe("isPreviewEnvironment", () => {
it('should return true when ROO_CODE_APP_ENV is "preview"', () => {
process.env.ROO_CODE_APP_ENV = "preview"
expect(isPreviewEnvironment()).toBe(true)
})
it('should return false when ROO_CODE_APP_ENV is "production"', () => {
process.env.ROO_CODE_APP_ENV = "production"
expect(isPreviewEnvironment()).toBe(false)
})
it('should return false when ROO_CODE_APP_ENV is "development"', () => {
process.env.ROO_CODE_APP_ENV = "development"
expect(isPreviewEnvironment()).toBe(false)
})
it("should return false when ROO_CODE_APP_ENV is not set", () => {
delete process.env.ROO_CODE_APP_ENV
expect(isPreviewEnvironment()).toBe(false)
})
})
describe("isProductionEnvironment", () => {
it('should return true when ROO_CODE_APP_ENV is "production"', () => {
process.env.ROO_CODE_APP_ENV = "production"
expect(isProductionEnvironment()).toBe(true)
})
it('should return false when ROO_CODE_APP_ENV is "preview"', () => {
process.env.ROO_CODE_APP_ENV = "preview"
expect(isProductionEnvironment()).toBe(false)
})
it("should return false when ROO_CODE_APP_ENV is not set", () => {
delete process.env.ROO_CODE_APP_ENV
expect(isProductionEnvironment()).toBe(false)
})
})
describe("isDevelopmentEnvironment", () => {
it('should return true when ROO_CODE_APP_ENV is "development"', () => {
process.env.ROO_CODE_APP_ENV = "development"
expect(isDevelopmentEnvironment()).toBe(true)
})
it('should return false when ROO_CODE_APP_ENV is "production"', () => {
process.env.ROO_CODE_APP_ENV = "production"
expect(isDevelopmentEnvironment()).toBe(false)
})
it("should return false when ROO_CODE_APP_ENV is not set", () => {
delete process.env.ROO_CODE_APP_ENV
expect(isDevelopmentEnvironment()).toBe(false)
})
})
})