From 239a57d284a7904cdb0123fcf59fc80601041638 Mon Sep 17 00:00:00 2001 From: Matias Chomicki Date: Mon, 30 Jun 2025 14:46:51 +0100 Subject: [PATCH] virtualization: test calculateFieldDimensions --- .../components/panel/virtualization.test.ts | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/public/app/features/logs/components/panel/virtualization.test.ts b/public/app/features/logs/components/panel/virtualization.test.ts index d01bf42d4c4..ff1789ad50e 100644 --- a/public/app/features/logs/components/panel/virtualization.test.ts +++ b/public/app/features/logs/components/panel/virtualization.test.ts @@ -38,7 +38,6 @@ describe('Virtualization', () => { beforeEach(() => { log = createLogLine({ labels: { place: 'luna' }, entry: `log message 1` }, preProcessOptions); - //virtualization = new LogLineVirtualization(createTheme(), 'default'); container = document.createElement('div'); jest.spyOn(container, 'clientWidth', 'get').mockReturnValue(CONTAINER_SIZE); LETTER_WIDTH = virtualization.measureTextWidth('e'); @@ -219,6 +218,29 @@ describe('Virtualization', () => { }); }); + describe('calculateFieldDimensions', () => { + test('Measures displayed fields including the log line body', () => { + expect(virtualization.calculateFieldDimensions([log], ['place', LOG_LINE_BODY_FIELD_NAME])).toEqual([ + { + field: 'timestamp', + width: 23, + }, + { + field: 'level', + width: 4, + }, + { + field: 'place', + width: 4, + }, + { + field: '___LOG_LINE_BODY___', + width: 13, + }, + ]); + }); + }); + describe('With small font size', () => { const virtualization = new LogLineVirtualization(createTheme(), 'small');