Skip to content

Commit ebbe4e5

Browse files
committed
update tests with init_microservices
1 parent d570729 commit ebbe4e5

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

tests/unit/composables/run_function_when_microservices_connected.nuxt.test.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,20 @@ describe("run_function_when_microservices_connected", () => {
3131
expect(spy).toHaveBeenCalled()
3232
})
3333

34-
test("microservices not connected", async () => {
34+
test("microservices not connected - does not call function", async () => {
35+
const infra_store = useInfraStore()
36+
infra_store.init_microservices()
3537
const geode_store = useGeodeStore()
3638
const viewer_store = useViewerStore()
3739
const spy = vi.spyOn(dumb_obj, "dumb_method")
40+
41+
geode_store.$patch({ status: Status.NOT_CONNECTED })
42+
viewer_store.$patch({ status: Status.NOT_CONNECTED })
43+
3844
run_function_when_microservices_connected(dumb_obj.dumb_method)
39-
await geode_store.$patch({ status: Status.NOT_CONNECTED })
40-
await viewer_store.$patch({ status: Status.NOT_CONNECTED })
45+
46+
await new Promise((resolve) => setTimeout(resolve, 200))
47+
4148
expect(spy).not.toHaveBeenCalled()
4249
})
4350
})

tests/unit/stores/Infra.nuxt.test.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ describe("Infra Store", () => {
6666
describe("lambda_url", () => {
6767
test("test is cloud true", () => {
6868
const infra_store = useInfraStore()
69+
infra_store.init_microservices()
6970
useRuntimeConfig().public.SITE_BRANCH = "/test"
7071
useRuntimeConfig().public.PROJECT = "/project"
7172
infra_store.app_mode = appMode.appMode.CLOUD
73+
const geode_store = useGeodeStore()
74+
geode_store.$patch({ protocol: "https", port: 443 })
7275
expect(infra_store.lambda_url).toBe(
7376
"https://api.geode-solutions.com:443/test/project/createbackend",
7477
)
@@ -77,6 +80,7 @@ describe("Infra Store", () => {
7780
describe("status", () => {
7881
test("test geode false & viewer false", () => {
7982
const infra_store = useInfraStore()
83+
infra_store.init_microservices()
8084
const geode_store = useGeodeStore()
8185
const viewer_store = useViewerStore()
8286
geode_store.$patch({ status: Status.NOT_CONNECTED })
@@ -85,6 +89,7 @@ describe("Infra Store", () => {
8589
})
8690
test("test geode true & viewer false", () => {
8791
const infra_store = useInfraStore()
92+
infra_store.init_microservices()
8893
const geode_store = useGeodeStore()
8994
const viewer_store = useViewerStore()
9095
geode_store.$patch({ status: Status.CONNECTED })
@@ -93,6 +98,7 @@ describe("Infra Store", () => {
9398
})
9499
test("test geode false & viewer true", () => {
95100
const infra_store = useInfraStore()
101+
infra_store.init_microservices()
96102
const geode_store = useGeodeStore()
97103
const viewer_store = useViewerStore()
98104
geode_store.$patch({ status: Status.NOT_CONNECTED })
@@ -101,6 +107,7 @@ describe("Infra Store", () => {
101107
})
102108
test("test geode true & viewer true", () => {
103109
const infra_store = useInfraStore()
110+
infra_store.init_microservices()
104111
const geode_store = useGeodeStore()
105112
const viewer_store = useViewerStore()
106113
geode_store.$patch({ status: Status.CONNECTED })
@@ -112,34 +119,38 @@ describe("Infra Store", () => {
112119
describe("is_busy", () => {
113120
test("test geode false & viewer false", () => {
114121
const infra_store = useInfraStore()
122+
infra_store.init_microservices()
115123
const geode_store = useGeodeStore()
116124
const viewer_store = useViewerStore()
117-
geode_store.$patch({ request_counter: 0 })
118-
viewer_store.$patch({ request_counter: 0 })
125+
geode_store.$patch({ is_busy: false })
126+
viewer_store.$patch({ is_busy: false })
119127
expect(infra_store.microservices_busy).toBe(false)
120128
})
121129
test("test geode true & viewer false", () => {
122130
const infra_store = useInfraStore()
131+
infra_store.init_microservices()
123132
const geode_store = useGeodeStore()
124133
const viewer_store = useViewerStore()
125-
geode_store.$patch({ request_counter: 1 })
126-
viewer_store.$patch({ request_counter: 0 })
134+
geode_store.$patch({ is_busy: true })
135+
viewer_store.$patch({ is_busy: false })
127136
expect(infra_store.microservices_busy).toBe(true)
128137
})
129138
test("test geode false & viewer true", () => {
130139
const infra_store = useInfraStore()
140+
infra_store.init_microservices()
131141
const geode_store = useGeodeStore()
132142
const viewer_store = useViewerStore()
133-
geode_store.$patch({ request_counter: 0 })
134-
viewer_store.$patch({ request_counter: 1 })
143+
geode_store.$patch({ is_busy: false })
144+
viewer_store.$patch({ is_busy: true })
135145
expect(infra_store.microservices_busy).toBe(true)
136146
})
137147
test("test geode true & viewer true", () => {
138148
const infra_store = useInfraStore()
149+
infra_store.init_microservices()
139150
const geode_store = useGeodeStore()
140151
const viewer_store = useViewerStore()
141-
geode_store.$patch({ request_counter: 1 })
142-
viewer_store.$patch({ request_counter: 1 })
152+
geode_store.$patch({ is_busy: true })
153+
viewer_store.$patch({ is_busy: true })
143154
expect(infra_store.microservices_busy).toBe(true)
144155
})
145156
})
@@ -149,6 +160,7 @@ describe("Infra Store", () => {
149160
describe("create_backend", () => {
150161
test("test without end-point", async () => {
151162
const infra_store = useInfraStore()
163+
infra_store.init_microservices()
152164
const geode_store = useGeodeStore()
153165
const viewer_store = useViewerStore()
154166
await infra_store.create_backend()

0 commit comments

Comments
 (0)