ShtukbaseStandard
archivo del paquete→ .shtukbase/packages/chat/test/tools-sync.test.ts

test/tools-sync.test.ts

22 líneas, 1.3 KB.

El archivo tal como está en el paquete: el código y sus comentarios no se traducen.

  1. // fs-store.js carries a copy of four tool schemas for file mode; keep it equal to tools.ts.
  2. import { expect, test } from 'bun:test';
  3. import { tools } from '../../../../shtuk/src/core/tools.ts';
  4. test('file-mode tools equal the shared tool list', async () => {
  5. const g: any = { window: {} as any };
  6. new Function('window', await Bun.file(new URL('../lens/fs-store.js', import.meta.url)).text())(g.window);
  7. for (const t of g.window.chatFs.tools) {
  8. expect(t).toEqual(tools.find((x) => x.name === t.name) as any);
  9. }
  10. expect(g.window.chatFs.tools.map((t: any) => t.name)).toEqual(['tree', 'records_list', 'records_read', 'records_write']);
  11. });
  12. test('front matter subset: parse and write back', async () => {
  13. const g: any = { window: {} as any };
  14. new Function('window', await Bun.file(new URL('../lens/fs-store.js', import.meta.url)).text())(g.window);
  15. const fs = g.window.chatFs;
  16. const page = fs._parse('---\ntype: Collection\ntitle: "Заявки"\nn: 3\nitems:\n path: /leads\ntags: [a, b]\nm: {k: v}\n---\nBody');
  17. expect(page.meta).toEqual({ type: 'Collection', title: 'Заявки', n: 3, items: { path: '/leads' }, tags: ['a', 'b'], m: { k: 'v' } });
  18. expect(page.body).toBe('Body');
  19. expect(fs._write('title: A\nitems:\n path: /x\nz: 1', { items: 'q', status: 'won' })).toBe('title: A\nitems: q\nz: 1\nstatus: won');
  20. });