|
1 | | -import { setActivePinia, createPinia } from "pinia" |
2 | 1 | import { describe, expect, test, beforeEach, vi } from "vitest" |
3 | 2 |
|
4 | 3 | describe("api_fetch.js", () => { |
5 | 4 | const geode_store = use_geode_store() |
6 | 5 | const websocket_store = use_websocket_store() |
7 | | - const cloud_store = use_cloud_store() |
8 | 6 |
|
9 | 7 | const dumb_obj = { dumb_method: () => true } |
10 | 8 |
|
11 | 9 | beforeEach(async () => { |
12 | | - setActivePinia(createPinia()) |
13 | 10 | await geode_store.$patch({ is_running: false }) |
14 | 11 | await websocket_store.$patch({ is_running: false }) |
15 | 12 | }) |
16 | 13 |
|
17 | 14 | test("is_running true", async () => { |
18 | 15 | const spy = vi.spyOn(dumb_obj, "dumb_method") |
19 | | - console.log("cloud_store.is_running", cloud_store.is_running) |
20 | 16 | await geode_store.$patch({ is_running: true }) |
21 | 17 | await websocket_store.$patch({ is_running: true }) |
22 | 18 |
|
23 | 19 | await runFunctionIfCloudRunning(dumb_obj.dumb_method) |
24 | 20 | expect(spy).toHaveBeenCalled() |
25 | 21 | }) |
26 | 22 |
|
27 | | - // test("is_running false", async () => { |
28 | | - // const spy = vi.spyOn(dumb_obj, "dumb_method") |
29 | | - // runFunctionIfCloudRunning(dumb_obj.dumb_method) |
30 | | - // // expect(spy).not.toHaveBeenCalled() |
31 | | - // await geode_store.$patch({ is_running: true }) |
32 | | - // await websocket_store.$patch({ is_running: true }) |
33 | | - // console.log("geode_store.is_running", geode_store.is_running) |
34 | | - // console.log("websocket_store.is_running", websocket_store.is_running) |
35 | | - // console.log("cloud_store.is_running", cloud_store.is_running) |
36 | | - |
37 | | - // expect(spy).toHaveBeenCalled() |
38 | | - // }) |
| 23 | + test("is_running false", async () => { |
| 24 | + const spy = vi.spyOn(dumb_obj, "dumb_method") |
| 25 | + runFunctionIfCloudRunning(dumb_obj.dumb_method) |
| 26 | + await geode_store.$patch({ is_running: true }) |
| 27 | + await websocket_store.$patch({ is_running: true }) |
| 28 | + expect(spy).toHaveBeenCalled() |
| 29 | + }) |
39 | 30 | }) |
0 commit comments