@flighthq/host-electron 0.5.1-next.920.da8f530 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/contract.d.ts +19 -24
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +18 -24
- package/dist/contract.js.map +1 -1
- package/dist/electronApp.d.ts +62 -34
- package/dist/electronApp.d.ts.map +1 -1
- package/dist/electronApp.js +175 -234
- package/dist/electronApp.js.map +1 -1
- package/dist/electronClipboard.d.ts +7 -5
- package/dist/electronClipboard.d.ts.map +1 -1
- package/dist/electronClipboard.js +91 -66
- package/dist/electronClipboard.js.map +1 -1
- package/dist/electronDefaultHostGroups.d.ts +59 -0
- package/dist/electronDefaultHostGroups.d.ts.map +1 -0
- package/dist/electronDefaultHostGroups.js +109 -0
- package/dist/electronDefaultHostGroups.js.map +1 -0
- package/dist/electronDialog.d.ts +12 -9
- package/dist/electronDialog.d.ts.map +1 -1
- package/dist/electronDialog.js +28 -21
- package/dist/electronDialog.js.map +1 -1
- package/dist/electronIpc.d.ts +13 -11
- package/dist/electronIpc.d.ts.map +1 -1
- package/dist/electronIpc.js +32 -26
- package/dist/electronIpc.js.map +1 -1
- package/dist/electronMenu.d.ts +12 -6
- package/dist/electronMenu.d.ts.map +1 -1
- package/dist/electronMenu.js +41 -30
- package/dist/electronMenu.js.map +1 -1
- package/dist/electronMenuTemplate.d.ts +2 -1
- package/dist/electronMenuTemplate.d.ts.map +1 -1
- package/dist/electronMenuTemplate.js.map +1 -1
- package/dist/electronNotification.d.ts +25 -7
- package/dist/electronNotification.d.ts.map +1 -1
- package/dist/electronNotification.js +39 -16
- package/dist/electronNotification.js.map +1 -1
- package/dist/electronPlatform.d.ts +5 -3
- package/dist/electronPlatform.d.ts.map +1 -1
- package/dist/electronPlatform.js +9 -7
- package/dist/electronPlatform.js.map +1 -1
- package/dist/electronPower.d.ts +22 -11
- package/dist/electronPower.d.ts.map +1 -1
- package/dist/electronPower.js +48 -59
- package/dist/electronPower.js.map +1 -1
- package/dist/electronProtocol.d.ts +16 -8
- package/dist/electronProtocol.d.ts.map +1 -1
- package/dist/electronProtocol.js +45 -28
- package/dist/electronProtocol.js.map +1 -1
- package/dist/electronRegister.d.ts +5 -7
- package/dist/electronRegister.d.ts.map +1 -1
- package/dist/electronRegister.js +72 -99
- package/dist/electronRegister.js.map +1 -1
- package/dist/electronScreen.d.ts +7 -6
- package/dist/electronScreen.d.ts.map +1 -1
- package/dist/electronScreen.js +17 -14
- package/dist/electronScreen.js.map +1 -1
- package/dist/electronShell.d.ts +16 -8
- package/dist/electronShell.d.ts.map +1 -1
- package/dist/electronShell.js +50 -43
- package/dist/electronShell.js.map +1 -1
- package/dist/electronShortcut.d.ts +6 -4
- package/dist/electronShortcut.d.ts.map +1 -1
- package/dist/electronShortcut.js +16 -10
- package/dist/electronShortcut.js.map +1 -1
- package/dist/electronStorage.d.ts +5 -3
- package/dist/electronStorage.d.ts.map +1 -1
- package/dist/electronStorage.js +9 -7
- package/dist/electronStorage.js.map +1 -1
- package/dist/electronTray.d.ts +38 -21
- package/dist/electronTray.d.ts.map +1 -1
- package/dist/electronTray.js +110 -76
- package/dist/electronTray.js.map +1 -1
- package/dist/electronUpdater.d.ts +6 -3
- package/dist/electronUpdater.d.ts.map +1 -1
- package/dist/electronUpdater.js +10 -7
- package/dist/electronUpdater.js.map +1 -1
- package/dist/electronWindow.d.ts +23 -7
- package/dist/electronWindow.d.ts.map +1 -1
- package/dist/electronWindow.js +234 -152
- package/dist/electronWindow.js.map +1 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/types/ElectronApi.d.ts +393 -0
- package/dist/types/ElectronApi.d.ts.map +1 -0
- package/dist/types/ElectronApi.js +20 -0
- package/dist/types/ElectronApi.js.map +1 -0
- package/dist/types/ElectronAppCapabilitiesFor.d.ts +8 -0
- package/dist/types/ElectronAppCapabilitiesFor.d.ts.map +1 -0
- package/dist/types/ElectronAppCapabilitiesFor.js +2 -0
- package/dist/types/ElectronAppCapabilitiesFor.js.map +1 -0
- package/dist/types/ElectronHost.d.ts +43 -0
- package/dist/types/ElectronHost.d.ts.map +1 -0
- package/dist/types/ElectronHost.js +2 -0
- package/dist/types/ElectronHost.js.map +1 -0
- package/dist/types/ElectronHostGroups.d.ts +85 -0
- package/dist/types/ElectronHostGroups.d.ts.map +1 -0
- package/dist/types/ElectronHostGroups.js +2 -0
- package/dist/types/ElectronHostGroups.js.map +1 -0
- package/dist/types/ElectronHostOptions.d.ts +7 -0
- package/dist/types/ElectronHostOptions.d.ts.map +1 -0
- package/dist/types/ElectronHostOptions.js +2 -0
- package/dist/types/ElectronHostOptions.js.map +1 -0
- package/dist/types/ElectronProtocolCapabilities.d.ts +3 -0
- package/dist/types/ElectronProtocolCapabilities.d.ts.map +1 -0
- package/dist/types/ElectronProtocolCapabilities.js +2 -0
- package/dist/types/ElectronProtocolCapabilities.js.map +1 -0
- package/dist/types/ElectronTrayCapabilitiesFor.d.ts +7 -0
- package/dist/types/ElectronTrayCapabilitiesFor.d.ts.map +1 -0
- package/dist/types/ElectronTrayCapabilitiesFor.js +2 -0
- package/dist/types/ElectronTrayCapabilitiesFor.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +42 -21
- package/src/electronApp.test.ts +158 -131
- package/src/electronClipboard.test.ts +40 -13
- package/src/electronDefaultHostGroups.test.ts +148 -0
- package/src/electronDialog.test.ts +55 -53
- package/src/electronHostTreeShaking.test.ts +51 -0
- package/src/electronIpc.test.ts +47 -66
- package/src/electronMenu.test.ts +61 -47
- package/src/electronMenuTemplate.test.ts +1 -1
- package/src/electronNotification.test.ts +71 -21
- package/src/electronPlatform.test.ts +17 -12
- package/src/electronPower.test.ts +112 -88
- package/src/electronProtocol.test.ts +68 -35
- package/src/electronRegister.test.ts +280 -26
- package/src/electronScreen.test.ts +34 -25
- package/src/electronShell.test.ts +99 -59
- package/src/electronShortcut.test.ts +22 -19
- package/src/electronStorage.test.ts +26 -24
- package/src/electronTray.test.ts +225 -109
- package/src/electronUpdater.test.ts +26 -19
- package/src/electronWindow.test.ts +229 -101
package/src/electronMenu.test.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ElectronApi, ElectronMenu, ElectronMenuItemOptions } from '@flighthq/types/contract';
|
|
3
|
-
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
1
|
+
import type { HostAppMenuCapability, HostMenuPopupCapability, HostMenuSelectCapability } from '@flighthq/menu/contract';
|
|
4
2
|
|
|
5
3
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
electronHostMenu,
|
|
5
|
+
electronHostAppMenu,
|
|
6
|
+
electronHostMenuPopup,
|
|
7
|
+
electronHostMenuSelect,
|
|
8
|
+
populateElectronHostMenu,
|
|
9
|
+
populateElectronHostAppMenu,
|
|
10
|
+
populateElectronHostMenuPopup,
|
|
11
|
+
populateElectronHostMenuSelect,
|
|
12
|
+
} from './electronMenu.ts';
|
|
13
|
+
import type { ElectronApi, ElectronMenu, ElectronMenuItemOptions } from './types/index.ts';
|
|
12
14
|
|
|
13
15
|
function fakeElectron(): {
|
|
14
16
|
electron: ElectronApi;
|
|
@@ -54,20 +56,36 @@ function clickItem(built: ElectronMenuItemOptions[][], id: string): void {
|
|
|
54
56
|
item?.click?.();
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
describe('
|
|
58
|
-
it('
|
|
59
|
-
|
|
60
|
-
expect(EntityRuntimeKey in capabilities).toBe(true);
|
|
61
|
-
for (const provider of Object.values(capabilities)) expect(EntityRuntimeKey in provider).toBe(true);
|
|
59
|
+
describe('electronHostAppMenu', () => {
|
|
60
|
+
it('constructs an app menu provider', () => {
|
|
61
|
+
expect(electronHostAppMenu(fakeElectron().electron)).toBeDefined();
|
|
62
62
|
});
|
|
63
|
+
});
|
|
64
|
+
// The merged MenuBackend is gone; these tests exercise the three slots that replaced it. This helper
|
|
65
|
+
// recomposes the old surface so each assertion still names the operation it is really testing.
|
|
66
|
+
function _slots(api: ElectronApi): {
|
|
67
|
+
destroy?: () => void;
|
|
68
|
+
popupContextMenu: HostMenuPopupCapability['popup'];
|
|
69
|
+
setAppMenu: HostAppMenuCapability['setAppMenu'];
|
|
70
|
+
subscribeSelect: HostMenuSelectCapability['subscribe'];
|
|
71
|
+
} {
|
|
72
|
+
const { app, popup, select } = electronHostMenu(api);
|
|
73
|
+
return {
|
|
74
|
+
destroy: app.destroy?.bind(app),
|
|
75
|
+
popupContextMenu: popup.popup,
|
|
76
|
+
setAppMenu: app.setAppMenu,
|
|
77
|
+
subscribeSelect: select.subscribe,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
63
80
|
|
|
81
|
+
describe('electronHostMenu', () => {
|
|
64
82
|
it('builds and applies the application menu and reports clicks via subscribeSelect', () => {
|
|
65
83
|
const { electron, built, applied } = fakeElectron();
|
|
66
84
|
const backend = _slots(electron);
|
|
67
85
|
const seen: string[] = [];
|
|
68
86
|
backend.subscribeSelect((id: string) => seen.push(id));
|
|
69
87
|
expect(
|
|
70
|
-
backend.
|
|
88
|
+
backend.setAppMenu([
|
|
71
89
|
{ id: 'open', label: 'Open' },
|
|
72
90
|
{ label: 'Edit', submenu: [{ id: 'copy', label: 'Copy' }] },
|
|
73
91
|
]),
|
|
@@ -83,7 +101,7 @@ describe('createElectronMenuBackends', () => {
|
|
|
83
101
|
const backend = _slots(electron);
|
|
84
102
|
const seen: string[] = [];
|
|
85
103
|
const unsubscribe = backend.subscribeSelect((id: string) => seen.push(id));
|
|
86
|
-
backend.
|
|
104
|
+
backend.setAppMenu([{ id: 'a', label: 'A' }]);
|
|
87
105
|
unsubscribe();
|
|
88
106
|
clickItem(built, 'a');
|
|
89
107
|
expect(seen).toEqual([]);
|
|
@@ -92,7 +110,7 @@ describe('createElectronMenuBackends', () => {
|
|
|
92
110
|
it('clears the native application menu on destroy', () => {
|
|
93
111
|
const { electron, applied } = fakeElectron();
|
|
94
112
|
const backend = _slots(electron);
|
|
95
|
-
backend.
|
|
113
|
+
backend.setAppMenu([{ id: 'a', label: 'A' }]);
|
|
96
114
|
expect(applied.length).toBe(1);
|
|
97
115
|
backend.destroy?.();
|
|
98
116
|
expect(applied.length).toBe(2);
|
|
@@ -102,7 +120,7 @@ describe('createElectronMenuBackends', () => {
|
|
|
102
120
|
it('clears the native application menu exactly once on double destroy', () => {
|
|
103
121
|
const { electron, applied } = fakeElectron();
|
|
104
122
|
const backend = _slots(electron);
|
|
105
|
-
backend.
|
|
123
|
+
backend.setAppMenu([{ id: 'a', label: 'A' }]);
|
|
106
124
|
expect(applied.length).toBe(1);
|
|
107
125
|
backend.destroy?.();
|
|
108
126
|
backend.destroy?.();
|
|
@@ -118,7 +136,7 @@ describe('createElectronMenuBackends', () => {
|
|
|
118
136
|
const backend = _slots(electron);
|
|
119
137
|
const seen: string[] = [];
|
|
120
138
|
const unsubscribe = backend.subscribeSelect((id: string) => seen.push(id));
|
|
121
|
-
backend.
|
|
139
|
+
backend.setAppMenu([{ id: 'a', label: 'A' }]);
|
|
122
140
|
backend.destroy?.();
|
|
123
141
|
clickItem(built, 'a');
|
|
124
142
|
expect(seen).toEqual(['a']);
|
|
@@ -139,42 +157,38 @@ describe('createElectronMenuBackends', () => {
|
|
|
139
157
|
});
|
|
140
158
|
});
|
|
141
159
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
describe('initializeElectronMenuCapabilities', () => {
|
|
159
|
-
it('is the construction initializer of createElectronMenuCapabilities', () => {
|
|
160
|
-
expect(typeof initializeElectronMenuCapabilities).toBe('function');
|
|
160
|
+
describe('electronHostMenuPopup', () => {
|
|
161
|
+
it('constructs a menu popup provider', () => {
|
|
162
|
+
expect(electronHostMenuPopup(fakeElectron().electron)).toBeDefined();
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe('electronHostMenuSelect', () => {
|
|
167
|
+
it('constructs a menu select provider', () => {
|
|
168
|
+
expect(electronHostMenuSelect()).toBeDefined();
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
describe('populateElectronHostAppMenu', () => {
|
|
173
|
+
it('is the construction initializer of electronHostMenuApplication', () => {
|
|
174
|
+
expect(typeof populateElectronHostAppMenu).toBe('function');
|
|
161
175
|
});
|
|
162
176
|
});
|
|
163
177
|
|
|
164
|
-
describe('
|
|
165
|
-
it('is the construction initializer of
|
|
166
|
-
expect(typeof
|
|
178
|
+
describe('populateElectronHostMenu', () => {
|
|
179
|
+
it('is the construction initializer of electronHostMenu', () => {
|
|
180
|
+
expect(typeof populateElectronHostMenu).toBe('function');
|
|
167
181
|
});
|
|
168
182
|
});
|
|
169
183
|
|
|
170
|
-
describe('
|
|
171
|
-
it('is the construction initializer of
|
|
172
|
-
expect(typeof
|
|
184
|
+
describe('populateElectronHostMenuPopup', () => {
|
|
185
|
+
it('is the construction initializer of electronHostMenuPopup', () => {
|
|
186
|
+
expect(typeof populateElectronHostMenuPopup).toBe('function');
|
|
173
187
|
});
|
|
174
188
|
});
|
|
175
189
|
|
|
176
|
-
describe('
|
|
177
|
-
it('is the construction initializer of
|
|
178
|
-
expect(typeof
|
|
190
|
+
describe('populateElectronHostMenuSelect', () => {
|
|
191
|
+
it('is the construction initializer of electronHostMenuSelect', () => {
|
|
192
|
+
expect(typeof populateElectronHostMenuSelect).toBe('function');
|
|
179
193
|
});
|
|
180
194
|
});
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
1
2
|
import { closeNotification } from '@flighthq/notification/contract';
|
|
2
|
-
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
3
|
-
import type { ElectronApi, ElectronNotificationOptions } from '@flighthq/types/contract';
|
|
4
3
|
|
|
5
4
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
electronHostNotification,
|
|
6
|
+
electronHostNotificationAction,
|
|
7
|
+
electronHostNotificationClick,
|
|
8
|
+
electronHostNotificationClose,
|
|
9
|
+
electronHostNotificationDelivery,
|
|
10
|
+
electronHostNotificationDismiss,
|
|
11
|
+
electronHostNotificationLifecycle,
|
|
12
|
+
electronHostNotificationReceived,
|
|
13
|
+
electronHostNotificationReply,
|
|
14
|
+
populateElectronHostNotificationMacos,
|
|
15
|
+
populateElectronHostNotificationCommon,
|
|
16
|
+
} from './electronNotification.ts';
|
|
17
|
+
import type { ElectronApi, ElectronNotificationOptions } from './types/index.ts';
|
|
10
18
|
|
|
11
19
|
interface FakeNotification {
|
|
12
20
|
close(): void;
|
|
@@ -38,20 +46,29 @@ function fakeElectron(supported = true) {
|
|
|
38
46
|
return { electron, notifications };
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
function notificationLeaf(factory: () => object): () => void {
|
|
50
|
+
return () => {
|
|
51
|
+
it('constructs a plain frozen notification provider without Entity', () => {
|
|
52
|
+
expect(EntityRuntimeKey in factory()).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
describe('electronHostNotification', () => {
|
|
42
58
|
it.each([
|
|
43
59
|
['macos', ['action', 'click', 'close', 'delivery', 'dismiss', 'lifecycle', 'received', 'reply']],
|
|
44
60
|
['windows', ['click', 'close', 'delivery', 'dismiss', 'lifecycle', 'received']],
|
|
45
61
|
['linux', ['click', 'close', 'delivery', 'dismiss', 'lifecycle', 'received']],
|
|
46
62
|
] as const)('constructs the exact %s profile', (platform, expected) => {
|
|
47
|
-
const capabilities =
|
|
48
|
-
expect(EntityRuntimeKey in capabilities).toBe(
|
|
63
|
+
const capabilities = electronHostNotification(fakeElectron().electron, { platform });
|
|
64
|
+
expect(EntityRuntimeKey in capabilities).toBe(false);
|
|
49
65
|
expect(Object.keys(capabilities).sort()).toEqual(expected);
|
|
66
|
+
for (const provider of Object.values(capabilities)) expect(EntityRuntimeKey in provider).toBe(false);
|
|
50
67
|
expect('permission' in capabilities).toBe(false);
|
|
51
68
|
});
|
|
52
69
|
|
|
53
70
|
it('rejects Darwin-only actions on Windows instead of dropping them', async () => {
|
|
54
|
-
const capabilities =
|
|
71
|
+
const capabilities = electronHostNotification(fakeElectron().electron, { platform: 'windows' });
|
|
55
72
|
await expect(
|
|
56
73
|
capabilities.delivery.notify({
|
|
57
74
|
actions: [{ id: 'open', title: 'Open' }],
|
|
@@ -62,7 +79,7 @@ describe('createElectronNotificationCapabilities', () => {
|
|
|
62
79
|
|
|
63
80
|
it('publishes only after the native show event', async () => {
|
|
64
81
|
const { electron, notifications } = fakeElectron();
|
|
65
|
-
const capabilities =
|
|
82
|
+
const capabilities = electronHostNotification(electron, {
|
|
66
83
|
platform: 'linux',
|
|
67
84
|
});
|
|
68
85
|
let show: (() => void) | null = null;
|
|
@@ -103,7 +120,7 @@ describe('createElectronNotificationCapabilities', () => {
|
|
|
103
120
|
},
|
|
104
121
|
{ isSupported: () => true },
|
|
105
122
|
) as unknown as ElectronApi['Notification'];
|
|
106
|
-
const capabilities =
|
|
123
|
+
const capabilities = electronHostNotification(electron, {
|
|
107
124
|
platform: 'linux',
|
|
108
125
|
});
|
|
109
126
|
await expect(capabilities.delivery.notify({ id: 'ghost', title: 'Ghost' })).resolves.toEqual({
|
|
@@ -119,7 +136,7 @@ describe('createElectronNotificationCapabilities', () => {
|
|
|
119
136
|
|
|
120
137
|
it('maps Darwin action/reply and all-platform click/dismiss/received to one Entity', async () => {
|
|
121
138
|
const { electron, notifications } = fakeElectron();
|
|
122
|
-
const capabilities =
|
|
139
|
+
const capabilities = electronHostNotification(electron, {
|
|
123
140
|
platform: 'macos',
|
|
124
141
|
});
|
|
125
142
|
const seen: string[] = [];
|
|
@@ -145,7 +162,7 @@ describe('createElectronNotificationCapabilities', () => {
|
|
|
145
162
|
|
|
146
163
|
it('pins close to the returned Entity', async () => {
|
|
147
164
|
const { electron, notifications } = fakeElectron();
|
|
148
|
-
const capabilities =
|
|
165
|
+
const capabilities = electronHostNotification(electron, {
|
|
149
166
|
platform: 'linux',
|
|
150
167
|
});
|
|
151
168
|
const delivered = await capabilities.delivery.notify({
|
|
@@ -168,7 +185,7 @@ describe('createElectronNotificationCapabilities', () => {
|
|
|
168
185
|
|
|
169
186
|
it('attempts all live closes and retries only failures', async () => {
|
|
170
187
|
const { electron, notifications } = fakeElectron();
|
|
171
|
-
const capabilities =
|
|
188
|
+
const capabilities = electronHostNotification(electron, {
|
|
172
189
|
platform: 'linux',
|
|
173
190
|
});
|
|
174
191
|
await capabilities.delivery.notify({ id: 'first', title: 'First' });
|
|
@@ -190,14 +207,47 @@ describe('createElectronNotificationCapabilities', () => {
|
|
|
190
207
|
expect(secondCloses).toBe(2);
|
|
191
208
|
});
|
|
192
209
|
});
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
210
|
+
const notificationAction = notificationLeaf(() =>
|
|
211
|
+
electronHostNotificationAction(fakeElectron().electron, { platform: 'macos' }),
|
|
212
|
+
);
|
|
213
|
+
const notificationClick = notificationLeaf(() =>
|
|
214
|
+
electronHostNotificationClick(fakeElectron().electron, { platform: 'linux' }),
|
|
215
|
+
);
|
|
216
|
+
const notificationClose = notificationLeaf(() =>
|
|
217
|
+
electronHostNotificationClose(fakeElectron().electron, { platform: 'linux' }),
|
|
218
|
+
);
|
|
219
|
+
const notificationDelivery = notificationLeaf(() =>
|
|
220
|
+
electronHostNotificationDelivery(fakeElectron().electron, { platform: 'linux' }),
|
|
221
|
+
);
|
|
222
|
+
const notificationDismiss = notificationLeaf(() =>
|
|
223
|
+
electronHostNotificationDismiss(fakeElectron().electron, { platform: 'linux' }),
|
|
224
|
+
);
|
|
225
|
+
const notificationLifecycle = notificationLeaf(() =>
|
|
226
|
+
electronHostNotificationLifecycle(fakeElectron().electron, { platform: 'linux' }),
|
|
227
|
+
);
|
|
228
|
+
const notificationReceived = notificationLeaf(() =>
|
|
229
|
+
electronHostNotificationReceived(fakeElectron().electron, { platform: 'linux' }),
|
|
230
|
+
);
|
|
231
|
+
const notificationReply = notificationLeaf(() =>
|
|
232
|
+
electronHostNotificationReply(fakeElectron().electron, { platform: 'macos' }),
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
describe('electronHostNotificationAction', notificationAction);
|
|
236
|
+
describe('electronHostNotificationClick', notificationClick);
|
|
237
|
+
describe('electronHostNotificationClose', notificationClose);
|
|
238
|
+
describe('electronHostNotificationDelivery', notificationDelivery);
|
|
239
|
+
describe('electronHostNotificationDismiss', notificationDismiss);
|
|
240
|
+
describe('electronHostNotificationLifecycle', notificationLifecycle);
|
|
241
|
+
describe('electronHostNotificationReceived', notificationReceived);
|
|
242
|
+
describe('electronHostNotificationReply', notificationReply);
|
|
243
|
+
describe('populateElectronHostNotificationCommon', () => {
|
|
244
|
+
it('is the construction initializer of electronHostNotification', () => {
|
|
245
|
+
expect(typeof populateElectronHostNotificationCommon).toBe('function');
|
|
196
246
|
});
|
|
197
247
|
});
|
|
198
248
|
|
|
199
|
-
describe('
|
|
200
|
-
it('is the construction initializer of
|
|
201
|
-
expect(typeof
|
|
249
|
+
describe('populateElectronHostNotificationMacos', () => {
|
|
250
|
+
it('is the construction initializer of electronHostNotification', () => {
|
|
251
|
+
expect(typeof populateElectronHostNotificationMacos).toBe('function');
|
|
202
252
|
});
|
|
203
253
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PlatformInfo
|
|
2
|
-
import { EntityRuntimeKey } from '@flighthq/types/contract';
|
|
1
|
+
import type { PlatformInfo } from '@flighthq/platform/contract';
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { electronHostPlatform, electronHostPlatformGroup, populateElectronHostPlatform } from './electronPlatform.ts';
|
|
4
|
+
import type { ElectronApi } from './types/index.ts';
|
|
5
5
|
|
|
6
6
|
function fakeElectron(): ElectronApi {
|
|
7
7
|
return {
|
|
@@ -11,13 +11,9 @@ function fakeElectron(): ElectronApi {
|
|
|
11
11
|
} as unknown as ElectronApi;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
describe('
|
|
15
|
-
it('returns an Entity', () => {
|
|
16
|
-
expect(EntityRuntimeKey in createElectronPlatformBackend(fakeElectron())).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
|
|
14
|
+
describe('electronHostPlatform', () => {
|
|
19
15
|
it('fills platform info from process and electron locale', () => {
|
|
20
|
-
const backend =
|
|
16
|
+
const backend = electronHostPlatform(fakeElectron());
|
|
21
17
|
const out = {} as PlatformInfo;
|
|
22
18
|
const result = backend.getInfo(out);
|
|
23
19
|
expect(result).toBe(out);
|
|
@@ -30,8 +26,17 @@ describe('createElectronPlatformBackend', () => {
|
|
|
30
26
|
expect(typeof out.version).toBe('string');
|
|
31
27
|
});
|
|
32
28
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
|
|
30
|
+
describe('electronHostPlatformGroup', () => {
|
|
31
|
+
it('constructs the platform info slot', () => {
|
|
32
|
+
const platform = electronHostPlatformGroup(fakeElectron());
|
|
33
|
+
expect(Object.keys(platform)).toEqual(['info']);
|
|
34
|
+
expect(platform.info.getInfo).toBeTypeOf('function');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('populateElectronHostPlatform', () => {
|
|
39
|
+
it('is the construction initializer of electronHostPlatform', () => {
|
|
40
|
+
expect(typeof populateElectronHostPlatform).toBe('function');
|
|
36
41
|
});
|
|
37
42
|
});
|