mirror of
https://github.com/router-for-me/Cli-Proxy-API-Management-Center.git
synced 2026-10-16 14:57:05 +08:00
27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import { shouldExitLogFullscreen } from '../src/features/logs/model/logFullscreen';
|
|
|
|
describe('log fullscreen Escape handling', () => {
|
|
test('an unhandled Escape exits fullscreen', () => {
|
|
expect(shouldExitLogFullscreen({ key: 'Escape', defaultPrevented: false }, false)).toBe(true);
|
|
});
|
|
|
|
test('Escape consumed by a nested Select does not exit fullscreen', () => {
|
|
expect(shouldExitLogFullscreen({ key: 'Escape', defaultPrevented: true }, false)).toBe(false);
|
|
// After the Select closes, the next unhandled Escape can exit fullscreen.
|
|
expect(shouldExitLogFullscreen({ key: 'Escape', defaultPrevented: false }, false)).toBe(true);
|
|
});
|
|
|
|
test('an open modal retains Escape priority', () => {
|
|
for (const defaultPrevented of [false, true]) {
|
|
expect(shouldExitLogFullscreen({ key: 'Escape', defaultPrevented }, true)).toBe(false);
|
|
}
|
|
});
|
|
|
|
test('other keys never exit fullscreen', () => {
|
|
for (const key of ['Enter', 'Tab', 'ArrowDown']) {
|
|
expect(shouldExitLogFullscreen({ key, defaultPrevented: false }, false)).toBe(false);
|
|
}
|
|
});
|
|
});
|