2025-11-24 23:11:46 +05:30
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { describe, it, expect, vi } from 'vitest';
|
|
|
|
|
import { calculateMainAreaWidth } from './ui-sizing.js';
|
|
|
|
|
import { type LoadedSettings } from '../../config/settings.js';
|
|
|
|
|
|
|
|
|
|
// Mock dependencies
|
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
|
|
|
isAlternateBufferEnabled: vi.fn(),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
vi.mock('../hooks/useAlternateBuffer.js', () => ({
|
|
|
|
|
isAlternateBufferEnabled: mocks.isAlternateBufferEnabled,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
describe('ui-sizing', () => {
|
|
|
|
|
const createSettings = (useFullWidth?: boolean): LoadedSettings =>
|
|
|
|
|
({
|
|
|
|
|
merged: {
|
|
|
|
|
ui: {
|
|
|
|
|
useFullWidth,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}) as unknown as LoadedSettings;
|
|
|
|
|
|
|
|
|
|
describe('calculateMainAreaWidth', () => {
|
|
|
|
|
it.each([
|
2026-01-26 15:23:54 -08:00
|
|
|
// expected, width, altBuffer
|
|
|
|
|
[80, 80, false],
|
|
|
|
|
[100, 100, false],
|
|
|
|
|
[79, 80, true],
|
|
|
|
|
[99, 100, true],
|
2025-11-24 23:11:46 +05:30
|
|
|
])(
|
2026-01-26 15:23:54 -08:00
|
|
|
'should return %i when width=%i and altBuffer=%s',
|
|
|
|
|
(expected, width, altBuffer) => {
|
2025-11-24 23:11:46 +05:30
|
|
|
mocks.isAlternateBufferEnabled.mockReturnValue(altBuffer);
|
2026-01-26 15:23:54 -08:00
|
|
|
const settings = createSettings();
|
2025-11-24 23:11:46 +05:30
|
|
|
|
|
|
|
|
expect(calculateMainAreaWidth(width, settings)).toBe(expected);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|