mirror of
https://github.com/Kaelio/ktx.git
synced 2026-07-13 11:22:11 +02:00
18 lines
619 B
TypeScript
18 lines
619 B
TypeScript
|
|
import { describe, expect, it } from 'vitest';
|
||
|
|
import { jsonSafeBigint, toJsonSafeRows } from '../../../src/connectors/shared/duckdb-json-safe.js';
|
||
|
|
|
||
|
|
describe('duckdb json-safe bigint', () => {
|
||
|
|
it('keeps safe-range bigints as numbers', () => {
|
||
|
|
expect(jsonSafeBigint(42n)).toBe(42);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('stringifies bigints beyond Number.MAX_SAFE_INTEGER', () => {
|
||
|
|
const big = BigInt(Number.MAX_SAFE_INTEGER) + 10n;
|
||
|
|
expect(jsonSafeBigint(big)).toBe(big.toString());
|
||
|
|
});
|
||
|
|
|
||
|
|
it('converts only bigint cells in a row matrix', () => {
|
||
|
|
expect(toJsonSafeRows([[1n, 'a', null]])).toEqual([[1, 'a', null]]);
|
||
|
|
});
|
||
|
|
});
|