@flighthq/tray 0.4.0-next.1903.50bfa67 → 0.4.0-next.1908.751021c
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/package.json +3 -3
- package/src/tray.test.ts +81 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/tray",
|
|
3
|
-
"version": "0.4.0-next.
|
|
3
|
+
"version": "0.4.0-next.1908.751021c",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/log": "0.4.0-next.
|
|
42
|
-
"@flighthq/types": "0.4.0-next.
|
|
41
|
+
"@flighthq/log": "0.4.0-next.1908.751021c",
|
|
42
|
+
"@flighthq/types": "0.4.0-next.1908.751021c"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^5.3.0"
|
package/src/tray.test.ts
CHANGED
|
@@ -34,6 +34,10 @@ import {
|
|
|
34
34
|
setTrayPressedIcon,
|
|
35
35
|
startTrayIconAnimation,
|
|
36
36
|
stopTrayIconAnimation,
|
|
37
|
+
explainTrayBackend,
|
|
38
|
+
installTrayHostBackend,
|
|
39
|
+
observeTrayHostResult,
|
|
40
|
+
resetTrayBackendForTest,
|
|
37
41
|
} from './tray';
|
|
38
42
|
|
|
39
43
|
// Fake backend state per icon.
|
|
@@ -253,6 +257,34 @@ describe('displayTrayBalloon', () => {
|
|
|
253
257
|
});
|
|
254
258
|
});
|
|
255
259
|
|
|
260
|
+
describe('explainTrayBackend', () => {
|
|
261
|
+
afterEach(() => resetTrayBackendForTest());
|
|
262
|
+
|
|
263
|
+
it('reports host-not-enabled when no backend is installed', () => {
|
|
264
|
+
resetTrayBackendForTest();
|
|
265
|
+
const explanation = explainTrayBackend();
|
|
266
|
+
expect(explanation.layer).toBe('host-not-enabled');
|
|
267
|
+
expect(explanation.conflict).toBe(false);
|
|
268
|
+
expect(explanation.viability).toBe('unobserved');
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('reports custom layer when a custom backend is set', () => {
|
|
272
|
+
setTrayBackend(fakeBackend());
|
|
273
|
+
expect(explainTrayBackend().layer).toBe('custom');
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('reports host layer when a host backend is installed', () => {
|
|
277
|
+
installTrayHostBackend(fakeBackend());
|
|
278
|
+
expect(explainTrayBackend().layer).toBe('host');
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('reports conflict when two different host backends are installed', () => {
|
|
282
|
+
installTrayHostBackend(fakeBackend());
|
|
283
|
+
installTrayHostBackend(fakeBackend());
|
|
284
|
+
expect(explainTrayBackend().conflict).toBe(true);
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
256
288
|
describe('getTrayBackend', () => {
|
|
257
289
|
it('falls back to a web backend', () => {
|
|
258
290
|
expect(getTrayBackend()).not.toBeNull();
|
|
@@ -384,6 +416,25 @@ describe('getTrayIconTooltip', () => {
|
|
|
384
416
|
});
|
|
385
417
|
});
|
|
386
418
|
|
|
419
|
+
describe('installTrayHostBackend', () => {
|
|
420
|
+
afterEach(() => resetTrayBackendForTest());
|
|
421
|
+
|
|
422
|
+
it('installs a host backend that getTrayBackend returns', () => {
|
|
423
|
+
const backend = fakeBackend();
|
|
424
|
+
installTrayHostBackend(backend);
|
|
425
|
+
expect(getTrayBackend()).toBe(backend);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
it('is first-host-wins: a second different backend sets conflict', () => {
|
|
429
|
+
const first = fakeBackend();
|
|
430
|
+
const second = fakeBackend();
|
|
431
|
+
installTrayHostBackend(first);
|
|
432
|
+
installTrayHostBackend(second);
|
|
433
|
+
expect(getTrayBackend()).toBe(first);
|
|
434
|
+
expect(explainTrayBackend().conflict).toBe(true);
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
|
|
387
438
|
describe('isTrayDestroyed', () => {
|
|
388
439
|
it('returns false for a live tray', () => {
|
|
389
440
|
const backend = fakeBackend();
|
|
@@ -442,6 +493,24 @@ describe('isTrayIconAnimating', () => {
|
|
|
442
493
|
});
|
|
443
494
|
});
|
|
444
495
|
|
|
496
|
+
describe('observeTrayHostResult', () => {
|
|
497
|
+
afterEach(() => resetTrayBackendForTest());
|
|
498
|
+
|
|
499
|
+
it('records a successful observation', () => {
|
|
500
|
+
installTrayHostBackend(fakeBackend());
|
|
501
|
+
observeTrayHostResult('create', true);
|
|
502
|
+
const explanation = explainTrayBackend();
|
|
503
|
+
expect(explanation.operation).toBe('create');
|
|
504
|
+
expect(explanation.viability).toBe('available');
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
it('records a failed observation', () => {
|
|
508
|
+
installTrayHostBackend(fakeBackend());
|
|
509
|
+
observeTrayHostResult('create', false);
|
|
510
|
+
expect(explainTrayBackend().viability).toBe('runtime-api-unavailable');
|
|
511
|
+
});
|
|
512
|
+
});
|
|
513
|
+
|
|
445
514
|
describe('onTrayEvent', () => {
|
|
446
515
|
it('delivers rich TrayEventData via the active backend', () => {
|
|
447
516
|
const backend = fakeBackend();
|
|
@@ -540,6 +609,18 @@ describe('removeTrayBalloon', () => {
|
|
|
540
609
|
});
|
|
541
610
|
});
|
|
542
611
|
|
|
612
|
+
describe('resetTrayBackendForTest', () => {
|
|
613
|
+
it('clears all backend slots', () => {
|
|
614
|
+
setTrayBackend(fakeBackend());
|
|
615
|
+
installTrayHostBackend(fakeBackend());
|
|
616
|
+
observeTrayHostResult('create', true);
|
|
617
|
+
resetTrayBackendForTest();
|
|
618
|
+
expect(explainTrayBackend().layer).toBe('host-not-enabled');
|
|
619
|
+
expect(explainTrayBackend().conflict).toBe(false);
|
|
620
|
+
expect(explainTrayBackend().viability).toBe('unobserved');
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
|
|
543
624
|
describe('setTrayAnimationGuard', () => {
|
|
544
625
|
afterEach(() => {
|
|
545
626
|
setTrayAnimationGuard(null);
|