package file→ .shtukbase/packages/chat/test/tools-sync.test.ts
test/tools-sync.test.ts
22 lines, 1.3 KB.
The file as it is in the package. Some comments in it may not be in English yet.
- // fs-store.js carries a copy of four tool schemas for file mode; keep it equal to tools.ts.
- import { expect, test } from 'bun:test';
- import { tools } from '../../../../shtuk/src/core/tools.ts';
- test('file-mode tools equal the shared tool list', async () => {
- const g: any = { window: {} as any };
- new Function('window', await Bun.file(new URL('../lens/fs-store.js', import.meta.url)).text())(g.window);
- for (const t of g.window.chatFs.tools) {
- expect(t).toEqual(tools.find((x) => x.name === t.name) as any);
- }
- expect(g.window.chatFs.tools.map((t: any) => t.name)).toEqual(['tree', 'records_list', 'records_read', 'records_write']);
- });
- test('front matter subset: parse and write back', async () => {
- const g: any = { window: {} as any };
- new Function('window', await Bun.file(new URL('../lens/fs-store.js', import.meta.url)).text())(g.window);
- const fs = g.window.chatFs;
- const page = fs._parse('---\ntype: Collection\ntitle: "Заявки"\nn: 3\nitems:\n path: /leads\ntags: [a, b]\nm: {k: v}\n---\nBody');
- expect(page.meta).toEqual({ type: 'Collection', title: 'Заявки', n: 3, items: { path: '/leads' }, tags: ['a', 'b'], m: { k: 'v' } });
- expect(page.body).toBe('Body');
- expect(fs._write('title: A\nitems:\n path: /x\nz: 1', { items: 'q', status: 'won' })).toBe('title: A\nitems: q\nz: 1\nstatus: won');
- });