From 69142bffe926f9fcb0a046192cf5eb7183364d56 Mon Sep 17 00:00:00 2001 From: Krishna Dhakal <7krishna7dhakal7@gmail.com> Date: Mon, 9 Oct 2023 12:43:40 +0545 Subject: [PATCH] Test: add empty test case in sheet utils (#76168) add empty test case in sheet utils --- public/app/core/utils/sheet.test.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/app/core/utils/sheet.test.ts b/public/app/core/utils/sheet.test.ts index cb8b46ecfeb..139dc02dc1a 100644 --- a/public/app/core/utils/sheet.test.ts +++ b/public/app/core/utils/sheet.test.ts @@ -5,6 +5,15 @@ import { DataFrame } from '@grafana/data'; import { workSheetToFrame } from './sheet'; describe('sheets', () => { + it('should handle an empty sheet', () => { + const emptySheet = utils.aoa_to_sheet([]); + const frame = workSheetToFrame(emptySheet); + + expect(frame.name).toBeUndefined(); + expect(frame.fields).toHaveLength(0); + expect(frame.length).toBe(0); + }); + it('will use first row as names', () => { const sheet = utils.aoa_to_sheet([ ['Number', 'String', 'Bool', 'Date', 'Object'],