52 lines
2.6 KiB
TypeScript
52 lines
2.6 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { cssRgb, paneVisibility, raiseSupported } from '../src/shell/paneModel.ts';
|
|
|
|
test('a shell overlay never parks a pane (no drop to low memory)', () => {
|
|
for (const raiseSupported of [true, false]) {
|
|
for (const overlay of [0, 1, 3]) {
|
|
assert.equal(paneVisibility({ shown: true, overlay, raiseSupported }).parked, false);
|
|
}
|
|
}
|
|
});
|
|
|
|
test('where the shell can rise above the tabs, an overlay never hides a shown pane', () => {
|
|
for (const overlay of [0, 1, 5]) {
|
|
assert.deepEqual(paneVisibility({ shown: true, overlay, raiseSupported: true }), { visible: true, parked: false });
|
|
}
|
|
});
|
|
|
|
test('where it cannot, an overlay hides shown panes so the shell draws above them', () => {
|
|
assert.deepEqual(paneVisibility({ shown: true, overlay: 1, raiseSupported: false }), { visible: false, parked: false });
|
|
assert.deepEqual(paneVisibility({ shown: true, overlay: 0, raiseSupported: false }), { visible: true, parked: false });
|
|
});
|
|
|
|
test('a pane that is not shown is hidden and parked either way', () => {
|
|
for (const raiseSupported of [true, false]) {
|
|
assert.deepEqual(paneVisibility({ shown: false, overlay: 0, raiseSupported }), { visible: false, parked: true });
|
|
assert.deepEqual(paneVisibility({ shown: false, overlay: 2, raiseSupported }), { visible: false, parked: true });
|
|
}
|
|
});
|
|
|
|
test('raising is used only when the native probe says yes and the developer switch is off', () => {
|
|
assert.equal(raiseSupported(true, false), true);
|
|
assert.equal(raiseSupported(true, true), false);
|
|
for (const probe of [false, undefined, null, 'true', 1]) assert.equal(raiseSupported(probe, false), false);
|
|
// With the switch on, an overlay hides shown panes again (the "before" behaviour).
|
|
assert.deepEqual(paneVisibility({ shown: true, overlay: 1, raiseSupported: raiseSupported(true, true) }), { visible: false, parked: false });
|
|
});
|
|
|
|
test('overlays opening and closing never change what a raised shell shows or parks', () => {
|
|
const seen = [0, 1, 2, 1, 0].map(overlay => paneVisibility({ shown: true, overlay, raiseSupported: true }));
|
|
assert.ok(seen.every(state => state.visible && !state.parked));
|
|
});
|
|
|
|
test('the window ground is read from computed colors', () => {
|
|
assert.deepEqual(cssRgb('rgb(7, 8, 12)'), [7, 8, 12]);
|
|
assert.deepEqual(cssRgb('rgba(250, 249, 246, 0.9)'), [250, 249, 246]);
|
|
assert.deepEqual(cssRgb(' rgb(12 34 56 / 1) '), [12, 34, 56]);
|
|
assert.equal(cssRgb('rgba(0, 0, 0, 0)'), null);
|
|
assert.equal(cssRgb('transparent'), null);
|
|
assert.equal(cssRgb('#07080c'), null);
|
|
assert.equal(cssRgb('rgb(a, b, c)'), null);
|
|
});
|