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
This commit is contained in:
49
ts/pkgs/duckdb-data-values/test/DuckDBArrayValue.test.ts
Normal file
49
ts/pkgs/duckdb-data-values/test/DuckDBArrayValue.test.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { expect, suite, test } from 'vitest';
|
||||
import { DuckDBArrayValue } from '../src/DuckDBArrayValue';
|
||||
import { DuckDBMapValue } from '../src/DuckDBMapValue';
|
||||
|
||||
suite('DuckDBArrayValue', () => {
|
||||
test('should render an empty array to the correct string', () => {
|
||||
expect(new DuckDBArrayValue([]).toString()).toStrictEqual('[]');
|
||||
});
|
||||
test('should render a single element array to the correct string', () => {
|
||||
expect(new DuckDBArrayValue([123]).toString()).toStrictEqual('[123]');
|
||||
});
|
||||
test('should render a multi-element array to the correct string', () => {
|
||||
expect(
|
||||
new DuckDBArrayValue(['abc', null, true, '']).toString(),
|
||||
).toStrictEqual(`['abc', NULL, true, '']`);
|
||||
});
|
||||
test('should render an array with nested arrays to the correct string', () => {
|
||||
expect(
|
||||
new DuckDBArrayValue([
|
||||
new DuckDBArrayValue([]),
|
||||
null,
|
||||
new DuckDBArrayValue([123, null, 'xyz']),
|
||||
]).toString(),
|
||||
).toStrictEqual(`[[], NULL, [123, NULL, 'xyz']]`);
|
||||
});
|
||||
test('toJson array with basic values', () => {
|
||||
expect(new DuckDBArrayValue([123, 'abc', null]).toJson()).toStrictEqual([
|
||||
123,
|
||||
'abc',
|
||||
null,
|
||||
]);
|
||||
});
|
||||
test('toJson array with complex values', () => {
|
||||
expect(
|
||||
new DuckDBArrayValue([
|
||||
new DuckDBMapValue([
|
||||
{ key: 'foo', value: 123 },
|
||||
{ key: 'bar', value: 'abc' },
|
||||
]),
|
||||
new DuckDBArrayValue([123, null, 'xyz']),
|
||||
null,
|
||||
]).toJson(),
|
||||
).toStrictEqual([
|
||||
{ "'foo'": 123, "'bar'": 'abc' },
|
||||
[123, null, 'xyz'],
|
||||
null,
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user