import { strict as assert } from "node:assert"; import { test } from "vitest"; import { displayCellValue } from "../../apps/desktop/src/lib/dataGrid/cellValue.ts"; test("displayCellValue returns NULL for null", () => { assert.equal(displayCellValue(null), "NULL"); }); test("displayCellValue returns string representation for booleans", () => { assert.equal(displayCellValue(true), "true"); assert.equal(displayCellValue(false), "false"); }); test("displayCellValue returns String for numbers", () => { assert.equal(displayCellValue(42), "42"); assert.equal(displayCellValue(-3.14), "-3.14"); assert.equal(displayCellValue(0), "0"); }); test("displayCellValue returns String for strings", () => { assert.equal(displayCellValue("hello"), "hello"); assert.equal(displayCellValue(""), ""); }); test("displayCellValue does not truncate long strings", () => { const long = "a".repeat(1000); assert.equal(displayCellValue(long), long); }); test("displayCellValue serializes JSON strings containing complex nested objects", () => { const payload = '{"metadata":{"version":"2.1.0","tags":["alpha","beta"],"flags":{"enabled":true,"nested":{"depth":3,"items":[{"id":1,"label":"a"},{"id":2,"label":"b"}]}}},"data":{"records":[{"key":"k-001","value":42},{"key":"k-002","value":-999}],"summary":{"total":3,"valid":2}}}'; assert.equal(displayCellValue(payload), payload); }); test("displayCellValue handles strings with unicode and special characters", () => { const unicodeStr = "δ½ ε₯½δΈη ππ