@@ -4,7 +4,7 @@ import { describe, test, expect, expectTypeOf, beforeEach, vi } from "vitest"
44import { registerEndpoint } from "@nuxt/test-utils/runtime"
55import back_schemas from "@geode/opengeodeweb-back/schemas.json"
66
7- describe ( "Geode Store" , ( ) => {
7+ describe ( "Geode Store" , async ( ) => {
88 const pinia = createTestingPinia ( {
99 stubActions : false ,
1010 } )
@@ -52,33 +52,40 @@ describe("Geode Store", () => {
5252
5353 test ( "test override default_local_port" , ( ) => {
5454 infra_store . is_cloud = false
55- geode_store . default_local_port = "8080 "
56- expect ( geode_store . port ) . toBe ( "8080 " )
55+ geode_store . default_local_port = "12 "
56+ expect ( geode_store . port ) . toBe ( "12 " )
5757 } )
5858 } )
5959
6060 describe ( "base_url" , ( ) => {
61- // test("test is_cloud false", () => {
62- // infra_store.is_cloud = false
63- // infra_store.domain_name = "localhost"
64- // expect(geode_store.base_url).toBe("http://localhost:5000")
65- // })
66- // test("test is_cloud true", async () => {
67- // infra_store.is_cloud = true
68- // infra_store.ID = "123456"
69- // infra_store.domain_name = "example.com"
70- // expect(geode_store.base_url).toBe(
71- // "https://example.com:443/123456/geode",
72- // )
73- // })
74- // test("test is_cloud true, ID empty", async () => {
75- // infra_store.is_cloud = true
76- // infra_store.ID = ""
77- // infra_store.domain_name = "example.com"
78- // expect(() => geode_store.base_url).toThrowError(
79- // "ID must not be empty in cloud mode",
80- // )
81- // })
61+ test ( "test is_cloud false" , ( ) => {
62+ console . log ( "is_cloud" )
63+ infra_store . is_cloud = false
64+ console . log ( "is_cloud" )
65+ infra_store . domain_name = "localhost"
66+ console . log ( "is_cloud" )
67+ const url = geode_store . port
68+ console . log ( "port" , url )
69+ const url2 = geode_store . base_url
70+ console . log ( "base_url" , url2 )
71+ expect ( geode_store . base_url ) . toBe ( "http://localhost:5000" )
72+ } )
73+ test ( "test is_cloud true" , async ( ) => {
74+ infra_store . is_cloud = true
75+ infra_store . ID = "123456"
76+ infra_store . domain_name = "example.com"
77+ expect ( geode_store . base_url ) . toBe (
78+ "https://example.com:443/123456/geode" ,
79+ )
80+ } )
81+ test ( "test is_cloud true, ID empty" , async ( ) => {
82+ infra_store . is_cloud = true
83+ infra_store . ID = ""
84+ infra_store . domain_name = "example.com"
85+ expect ( ( ) => geode_store . base_url ) . toThrowError (
86+ "ID must not be empty in cloud mode" ,
87+ )
88+ } )
8289 } )
8390
8491 describe ( "is_busy" , ( ) => {
@@ -93,51 +100,30 @@ describe("Geode Store", () => {
93100 } )
94101 } )
95102
96- describe ( "actions" , ( ) => {
97- describe ( "do_ping" , ( ) => {
98-
99- // beforeEach(() => {
100- // infra_store.$reset()
101- // geode_store.$reset()
102- // feedback_store.$reset()
103- // })
104-
105-
106- geode_store . base_url = ""
103+ describe ( "actions" , async ( ) => {
104+ describe ( "do_ping" , async ( ) => {
107105 const getFakeCall = vi . fn ( )
108106 registerEndpoint ( back_schemas . opengeodeweb_back . ping . $id , getFakeCall )
109107
110- // test("request_error", async () => {
111- // geode_store.base_url = ""
112- // getFakeCall.mockImplementation(() => {
113- // throw createError({
114- // status: 404,
115- // })
116- // })
117-
118- // await geode_store.do_ping()
119- // expect(geode_store.is_running).toBe(false)
120- // expect(feedback_store.server_error).toBe(true)
121- // })
122-
123108 test ( "response" , async ( ) => {
124109 geode_store . base_url = ""
125- getFakeCall . mockImplementation ( ( ) => ( { test : 123 } ) ) ;
110+ getFakeCall . mockImplementation ( ( ) => ( { } ) )
126111 await geode_store . do_ping ( )
127112 expect ( geode_store . is_running ) . toBe ( true )
128113 expect ( feedback_store . server_error ) . toBe ( false )
129114 } )
130- // test("response_error", async () => {
131- // geode_store.base_url = ""
132- // getFakeCall.mockImplementation(() => {
133- // throw createError({
134- // status: 500,
135- // })
136- // })
137- // await geode_store.do_ping()
138- // expect(geode_store.is_running).toBe(false)
139- // expect(feedback_store.server_error).toBe(true)
140- // })
115+ test ( "response_error" , async ( ) => {
116+ geode_store . base_url = ""
117+ getFakeCall . mockImplementation ( ( ) => {
118+ throw createError ( {
119+ status : 500 ,
120+ } )
121+ } )
122+
123+ await geode_store . do_ping ( )
124+ expect ( geode_store . is_running ) . toBe ( false )
125+ expect ( feedback_store . server_error ) . toBe ( true )
126+ } )
141127 } )
142128
143129 describe ( "start_request" , ( ) => {
0 commit comments