Initial commit: bface library, build fixes, and refreshed docs
- Externalize all @tamagui/* and tamagui subpaths so dist no longer vendors Tamagui. - Emit TypeScript declarations with vite-plugin-dts; fix package exports types for ui/*. - Align initEnv with profiles: displayName, brandLogo, api.baseURL, themeColor, uiShell. - Stabilize tests with Node localStorage file; env tests pass. - Update README and component docs for services, menus, API client, and development.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { describe, test } from 'node:test';
|
||||
import assert from 'node:assert';
|
||||
import { GridDataModel } from '../src/ui/components/grid/model.js';
|
||||
|
||||
const rows = [
|
||||
{ id: 1, name: 'Northwind', status: 'open', total: 1200 },
|
||||
{ id: 2, name: 'Blue Harbor', status: 'review', total: 800 },
|
||||
{ id: 3, name: 'Summit', status: 'open', total: 2400 },
|
||||
{ id: 4, name: 'Lattice', status: 'closed', total: 400 }
|
||||
];
|
||||
|
||||
describe('GridDataModel', () => {
|
||||
test('queryStructure infers columns from row data', async () => {
|
||||
const model = new GridDataModel({ rows });
|
||||
const result = await model.queryStructure();
|
||||
|
||||
assert.ok(result.columns.name);
|
||||
assert.ok(result.columns.status);
|
||||
assert.ok(result.columns.total);
|
||||
assert.strictEqual(result.columns.total.align, 'right');
|
||||
});
|
||||
|
||||
test('queryRecords filters, sorts, and paginates', async () => {
|
||||
const model = new GridDataModel({ rows });
|
||||
const result = await model.queryRecords({
|
||||
filter_by: { status: 'open' },
|
||||
sort_by: [{ field: 'total', direction: 'desc' }],
|
||||
offset: 0,
|
||||
page_size: 1
|
||||
});
|
||||
|
||||
assert.strictEqual(result.total, 2);
|
||||
assert.strictEqual(result.rows.length, 1);
|
||||
assert.strictEqual(result.rows[0].name, 'Summit');
|
||||
});
|
||||
|
||||
test('queryRecords supports text search through search filter', async () => {
|
||||
const model = new GridDataModel({ rows });
|
||||
const result = await model.queryRecords({
|
||||
filter_by: { search: 'harbor' }
|
||||
});
|
||||
|
||||
assert.strictEqual(result.total, 1);
|
||||
assert.strictEqual(result.rows[0].name, 'Blue Harbor');
|
||||
});
|
||||
|
||||
test('queryAggregates supports count and sum metrics', async () => {
|
||||
const model = new GridDataModel({ rows });
|
||||
const result = await model.queryAggregates({
|
||||
metrics: ['count', 'sum:total'],
|
||||
filter_by: { status: 'open' }
|
||||
});
|
||||
|
||||
assert.strictEqual(result.count, 2);
|
||||
assert.strictEqual(result['sum:total'], 3600);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user