Skip to content

Commit 3071551

Browse files
feat(app_mode): wip fix unit tests
1 parent 5ed4e17 commit 3071551

File tree

3 files changed

+65
-41
lines changed

3 files changed

+65
-41
lines changed

test/stores/Geode.nuxt.test.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,52 +28,60 @@ describe("Geode Store", () => {
2828
})
2929
})
3030

31+
3132
describe("getters", () => {
3233
describe("protocol", () => {
33-
test("test is_cloud true", () => {
34-
infra_store.is_cloud = true
34+
test("test app_mode CLOUD", () => {
35+
infra_store.app_mode = appMode.appMode.CLOUD
3536
expect(geode_store.protocol).toBe("https")
3637
})
37-
38-
test("test is_cloud false", () => {
39-
infra_store.is_cloud = false
38+
test("test app_mode BROWSER", () => {
39+
infra_store.app_mode = appMode.appMode.BROWSER
40+
expect(geode_store.protocol).toBe("http")
41+
})
42+
test("test app_mode DESKTOP", () => {
43+
infra_store.app_mode = appMode.appMode.DESKTOP
4044
expect(geode_store.protocol).toBe("http")
4145
})
4246
})
4347

4448
describe("port", () => {
45-
test("test is_cloud true", () => {
46-
infra_store.is_cloud = true
49+
test("test app_mode CLOUD", () => {
50+
infra_store.app_mode = appMode.appMode.CLOUD
4751
expect(geode_store.port).toBe("443")
4852
})
49-
test("test is_cloud false", () => {
50-
infra_store.is_cloud = false
53+
test("test app_mode BROWSER", () => {
54+
infra_store.app_mode = appMode.appMode.BROWSER
55+
expect(geode_store.port).toBe(geode_store.default_local_port)
56+
})
57+
test("test app_mode DESKTOP", () => {
58+
infra_store.app_mode = appMode.appMode.DESKTOP
5159
expect(geode_store.port).toBe(geode_store.default_local_port)
5260
})
5361

5462
test("test override default_local_port", () => {
55-
infra_store.is_cloud = false
63+
infra_store.app_mode = appMode.appMode.DESKTOP
5664
geode_store.default_local_port = "12"
5765
expect(geode_store.port).toBe("12")
5866
})
5967
})
6068

6169
describe("base_url", () => {
62-
test("test is_cloud false", () => {
63-
infra_store.is_cloud = false
70+
test("test app_mode BROWSER", () => {
71+
infra_store.app_mode = appMode.appMode.BROWSER
6472
infra_store.domain_name = "localhost"
6573
expect(geode_store.base_url).toBe("http://localhost:5000")
6674
})
67-
test("test is_cloud true", () => {
68-
infra_store.is_cloud = true
75+
test("test app_mode CLOUD", () => {
76+
infra_store.app_mode = appMode.appMode.CLOUD
6977
infra_store.ID = "123456"
7078
infra_store.domain_name = "example.com"
7179
expect(geode_store.base_url).toBe(
7280
"https://example.com:443/123456/geode",
7381
)
7482
})
75-
test("test is_cloud true, ID empty", () => {
76-
infra_store.is_cloud = true
83+
test("test app_mode CLOUD, ID empty", () => {
84+
infra_store.app_mode = appMode.appMode.CLOUD
7785
infra_store.ID = ""
7886
infra_store.domain_name = "example.com"
7987
expect(() => geode_store.base_url).toThrowError(

test/stores/Infra.nuxt.test.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,23 @@ describe("Infra Store", () => {
4040
})
4141
})
4242
describe("getters", () => {
43-
describe("is_cloud", () => {
43+
describe("app_mode", () => {
4444
test("test type", () => {
45-
expectTypeOf(infra_store.is_cloud).toBeBoolean()
45+
expectTypeOf(infra_store.app_mode).toBeString()
4646
})
4747
})
4848

4949
describe("domain_name", () => {
50-
test("test type", () => {
51-
expectTypeOf(infra_store.is_cloud).toBeString()
50+
test("test app_mode BROWSER", () => {
51+
infra_store.app_mode = appMode.appMode.BROWSER
52+
expect(infra_store.domain_name).toBe("localhost")
5253
})
53-
test("test is_cloud false", () => {
54-
infra_store.is_cloud = false
54+
test("test app_mode DESKTOP", () => {
55+
infra_store.app_mode = appMode.appMode.DESKTOP
5556
expect(infra_store.domain_name).toBe("localhost")
5657
})
57-
test("test is_cloud false", () => {
58-
infra_store.is_cloud = true
58+
test("test app_mode CLOUD", () => {
59+
infra_store.app_mode = appMode.appMode.CLOUD
5960
expect(infra_store.domain_name).toBe("api.geode-solutions.com")
6061
})
6162
})
@@ -64,7 +65,7 @@ describe("Infra Store", () => {
6465
test("test is cloud true", () => {
6566
useRuntimeConfig().public.SITE_BRANCH = "/test"
6667
useRuntimeConfig().public.PROJECT = "/project"
67-
infra_store.is_cloud = true
68+
infra_store.app_mode = appMode.appMode.CLOUD
6869
expect(infra_store.lambda_url).toBe(
6970
"https://api.geode-solutions.com:443/test/project/createbackend",
7071
)

test/stores/Viewer.nuxt.test.js

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { setActivePinia } from "pinia"
22
import { createTestingPinia } from "@pinia/testing"
33
import { describe, test, expect, expectTypeOf, beforeEach } from "vitest"
4+
import { useRuntimeConfig } from "nuxt/app"
45

56
describe("Viewer Store", () => {
67
const pinia = createTestingPinia({
@@ -30,51 +31,65 @@ describe("Viewer Store", () => {
3031

3132
describe("getters", () => {
3233
describe("protocol", () => {
33-
test("test is_cloud true", () => {
34-
infra_store.is_cloud = true
34+
test("test app_mode CLOUD", () => {
35+
infra_store.app_mode = appMode.appMode.CLOUD
3536
expect(viewer_store.protocol).toBe("wss")
3637
})
37-
38-
test("test is_cloud false", () => {
39-
infra_store.is_cloud = false
38+
test("test app_mode BROWSER", () => {
39+
infra_store.app_mode = appMode.appMode.BROWSER
40+
expect(viewer_store.protocol).toBe("ws")
41+
})
42+
test("test app_mode DESKTOP", () => {
43+
infra_store.app_mode = appMode.appMode.DESKTOP
4044
expect(viewer_store.protocol).toBe("ws")
4145
})
4246
})
4347

4448
describe("port", () => {
45-
test("test is_cloud true", () => {
46-
infra_store.is_cloud = true
49+
test("test app_mode CLOUD", () => {
50+
infra_store.app_mode = appMode.appMode.CLOUD
4751
expect(viewer_store.port).toBe("443")
4852
})
49-
test("test is_cloud false", () => {
50-
infra_store.is_cloud = false
53+
test("test app_mode BROWSER", () => {
54+
infra_store.app_mode = appMode.appMode.BROWSER
55+
expect(viewer_store.port).toBe(viewer_store.default_local_port)
56+
})
57+
test("test app_mode DESKTOP", () => {
58+
infra_store.app_mode = appMode.appMode.DESKTOP
5159
expect(viewer_store.port).toBe(viewer_store.default_local_port)
5260
})
5361

5462
test("test override default_local_port", () => {
55-
infra_store.is_cloud = false
63+
infra_store.app_mode = appMode.appMode.DESKTOP
5664
viewer_store.default_local_port = "8080"
5765
expect(viewer_store.port).toBe("8080")
5866
})
67+
68+
test("test env VIEWER_PORT", () => {
69+
process.env.VIEWER_PORT = "8080"
70+
infra_store.app_mode = appMode.appMode.DESKTOP
71+
console.log("VIEWER_PORT", useRuntimeConfig().public.VIEWER_PORT)
72+
expect(viewer_store.port).toBe("8080")
73+
})
5974
})
6075
describe("base_url", () => {
61-
test("test is_cloud false", () => {
62-
infra_store.is_cloud = false
76+
test("test app_mode DESKTOP", () => {
77+
infra_store.app_mode = appMode.appMode.DESKTOP
6378
infra_store.domain_name = "localhost"
6479
expect(viewer_store.base_url).toBe("ws://localhost:1234/ws")
6580
})
6681

67-
test("test is_cloud true", () => {
68-
infra_store.is_cloud = true
82+
test("test app_mode CLOUD", () => {
83+
infra_store.app_mode = appMode.appMode.CLOUD
6984
infra_store.ID = "123456"
7085
infra_store.domain_name = "example.com"
7186
expect(viewer_store.base_url).toBe(
7287
"wss://example.com:443/123456/viewer/ws",
7388
)
7489
})
7590

76-
test("test is_cloud true, ID empty", () => {
77-
infra_store.is_cloud = true
91+
test("test app_mode CLOUD, ID empty", () => {
92+
infra_store.app_mode = appMode.appMode.CLOUD
7893
infra_store.ID = ""
7994
infra_store.domain_name = "example.com"
8095
expect(() => viewer_store.base_url).toThrowError(

0 commit comments

Comments
 (0)