diff options
Diffstat (limited to 'packages/renderer/src/env/impl/__tests__')
-rw-r--r-- | packages/renderer/src/env/impl/__tests__/RendererEnvImpl.spec.ts | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/packages/renderer/src/env/impl/__tests__/RendererEnvImpl.spec.ts b/packages/renderer/src/env/impl/__tests__/RendererEnvImpl.spec.ts deleted file mode 100644 index d36462c..0000000 --- a/packages/renderer/src/env/impl/__tests__/RendererEnvImpl.spec.ts +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2022 Kristóf Marussy <kristof@marussy.com> | ||
3 | * | ||
4 | * This file is part of Sophie. | ||
5 | * | ||
6 | * Sophie is free software: you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU Affero General Public License as | ||
8 | * published by the Free Software Foundation, version 3. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU Affero General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Affero General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | * | ||
18 | * SPDX-License-Identifier: AGPL-3.0-only | ||
19 | */ | ||
20 | |||
21 | import { jest } from '@jest/globals'; | ||
22 | import { | ||
23 | Action, | ||
24 | runtimeService, | ||
25 | RuntimeService, | ||
26 | SophieRenderer, | ||
27 | } from '@sophie/shared'; | ||
28 | |||
29 | import { rendererStore } from '../../../stores/RendererStore'; | ||
30 | import RendererEnvImpl from '../RendererEnvImpl'; | ||
31 | |||
32 | const ipc: SophieRenderer = { | ||
33 | dispatchAction: jest.fn(), | ||
34 | onSharedStoreChange: jest.fn(), | ||
35 | }; | ||
36 | let sut: RendererEnvImpl; | ||
37 | |||
38 | beforeEach(() => { | ||
39 | sut = new RendererEnvImpl(ipc); | ||
40 | }); | ||
41 | |||
42 | describe('dispatchMainAction', () => { | ||
43 | it('should dispatch actions via the IPC', () => { | ||
44 | const action: Action = { | ||
45 | action: 'set-theme-source', | ||
46 | themeSource: 'dark', | ||
47 | }; | ||
48 | sut.dispatchMainAction(action); | ||
49 | expect(ipc.dispatchAction).toHaveBeenCalledWith(action); | ||
50 | }); | ||
51 | }); | ||
52 | |||
53 | describe('getRuntimeService', () => { | ||
54 | describe('when no store was set', () => { | ||
55 | it('should throw an error', () => { | ||
56 | expect(() => sut.getRuntimeService('someId')).toThrow(); | ||
57 | }); | ||
58 | }); | ||
59 | |||
60 | describe('when the store was set', () => { | ||
61 | let runtimeServiceStore: RuntimeService; | ||
62 | |||
63 | beforeEach(() => { | ||
64 | runtimeServiceStore = runtimeService.create({ | ||
65 | state: 'loaded', | ||
66 | }); | ||
67 | const store = rendererStore.create({ | ||
68 | shared: { | ||
69 | runtimeServices: { | ||
70 | someId: runtimeServiceStore, | ||
71 | }, | ||
72 | }, | ||
73 | }); | ||
74 | sut.setStore(store); | ||
75 | }); | ||
76 | |||
77 | it('should return the runtime service for the given ID', () => { | ||
78 | const returnedStore = sut.getRuntimeService('someId'); | ||
79 | expect(returnedStore).toBe(runtimeServiceStore); | ||
80 | }); | ||
81 | |||
82 | it('should return undefined for an unknown ID', () => { | ||
83 | const returnedStore = sut.getRuntimeService('unknownId'); | ||
84 | expect(returnedStore).toBeUndefined(); | ||
85 | }); | ||
86 | }); | ||
87 | }); | ||