import assert from 'node:assert/strict'; import test from 'node:test'; import { isSameCellValue } from './formulaUtils.js'; // AURORA-1891: handleSave (EditCell.jsx) не должен слать cell_updated, если // значение фактически не изменилось — иначе лишняя запись в БД/аудите при // открытии и закрытии ячейки без правки. test('a numeric string equals the same number', () => { assert.equal(isSameCellValue('1500', 1500), true); }); test('a thousands-separated, comma-decimal value equals the plain number', () => { assert.equal(isSameCellValue('1 500,0', 1500), true); }); test('empty string and null both mean "no value"', () => { assert.equal(isSameCellValue('', null), true); assert.equal(isSameCellValue(null, ''), true); assert.equal(isSameCellValue(undefined, ''), true); assert.equal(isSameCellValue(undefined, null), true); }); test('a formula is never treated as unchanged, even against identical formula text', () => { assert.equal(isSameCellValue('=1+2', '=1+2'), false); assert.equal(isSameCellValue('=1+1', 2), false); assert.equal(isSameCellValue(2, '=1+1'), false); }); test('different values (numeric or text) are not the same', () => { assert.equal(isSameCellValue('1500', 1501), false); assert.equal(isSameCellValue('abc', 'abd'), false); assert.equal(isSameCellValue('1500', ''), false); }); test('non-numeric text compares as-is after trimming surrounding whitespace', () => { assert.equal(isSameCellValue(' текст ', 'текст'), true); }); test('isSameCellValue treats a numeric string and a number as equal', () => { assert.equal(isSameCellValue('150', 150), true); }); test('isSameCellValue treats an empty string and null as equal', () => { assert.equal(isSameCellValue('', null), true); }); test('isSameCellValue treats a numeric string with a trailing .0 as equal to the plain number', () => { assert.equal(isSameCellValue('150.0', 150), true); }); test('isSameCellValue treats different numbers as not equal', () => { assert.equal(isSameCellValue('151', 150), false); });