Files
duckdb-ui/ts/pkgs/duckdb-data-values/test/DuckDBTimestampMicrosecondsValue.test.ts
Jeff Raymakers 0edb52054a add duckdb-ui-client & other ts pkgs (#10)
* add duckdb-ui-client & other ts pkgs

* workflow fixes

* fix working dir

* no sparse checkout; specify package.json path

* path to pnpm-lock.yaml

* add check & build test

* workflow step descriptions

* use comments & names

* one more naming tweak
2025-06-13 09:16:05 -07:00

56 lines
2.4 KiB
TypeScript

import { expect, suite, test } from 'vitest';
import { DuckDBTimestampMicrosecondsValue } from '../src/DuckDBTimestampMicrosecondsValue';
suite('DuckDBTimestampMicrosecondsValue', () => {
test('should render a normal timestamp value to the correct string', () => {
expect(
new DuckDBTimestampMicrosecondsValue(1612325106007800n).toString(),
).toStrictEqual('2021-02-03 04:05:06.0078');
});
test('should render a zero timestamp value to the correct string', () => {
expect(new DuckDBTimestampMicrosecondsValue(0n).toString()).toStrictEqual(
'1970-01-01 00:00:00',
);
});
test('should render a negative timestamp value to the correct string', () => {
expect(new DuckDBTimestampMicrosecondsValue(-7n).toString()).toStrictEqual(
'1969-12-31 23:59:59.999993',
);
});
test('should render a large positive timestamp value to the correct string', () => {
expect(
new DuckDBTimestampMicrosecondsValue(2353318271999999000n).toString(),
).toStrictEqual('76543-09-08 23:59:59.999');
});
test('should render a large negative (AD) timestamp value to the correct string', () => {
expect(
new DuckDBTimestampMicrosecondsValue(-58261244276543211n).toString(),
).toStrictEqual('0123-10-11 01:02:03.456789');
});
test('should render a large negative (BC) timestamp value to the correct string', () => {
expect(
new DuckDBTimestampMicrosecondsValue(-65992661876543211n).toString(),
).toStrictEqual('0123-10-11 (BC) 01:02:03.456789');
});
test('should render the max timestamp value to the correct string', () => {
expect(
new DuckDBTimestampMicrosecondsValue(9223372036854775806n).toString(),
).toStrictEqual('294247-01-10 04:00:54.775806');
});
test('should render the min timestamp value to the correct string', () => {
expect(
new DuckDBTimestampMicrosecondsValue(-9223372022400000000n).toString(),
).toStrictEqual('290309-12-22 (BC) 00:00:00');
});
test('should render the positive infinity timestamp value to the correct string', () => {
expect(
new DuckDBTimestampMicrosecondsValue(9223372036854775807n).toString(),
).toStrictEqual('infinity');
});
test('should render the negative infinity timestamp value to the correct string', () => {
expect(
new DuckDBTimestampMicrosecondsValue(-9223372036854775807n).toString(),
).toStrictEqual('-infinity');
});
});