hub-list-sort.test.mjs
39 lines 1.6 KB
Raw
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd feat(calendar): enforce agent context tiers in retrieval AP… Human minor ⚠ breaking 1 day ago
1 import { test } from 'node:test';
2 import assert from 'node:assert/strict';
3 import { sortNotesList, sortProposalsList } from '../web/hub/hub-list-sort.mjs';
4
5 test('sortNotesList date_desc and date_asc', () => {
6 const notes = [
7 { path: 'a.md', date: '2020-01-01', updated: null },
8 { path: 'b.md', date: '2022-06-01', updated: null },
9 { path: 'c.md', date: '2021-01-01', updated: null },
10 ];
11 const dk = (n) => n.date || '';
12 const d = sortNotesList(notes, 'date_desc', dk).map((n) => n.path);
13 assert.deepEqual(d, ['b.md', 'c.md', 'a.md']);
14 const asc = sortNotesList(notes, 'date_asc', dk).map((n) => n.path);
15 assert.deepEqual(asc, ['a.md', 'c.md', 'b.md']);
16 });
17
18 test('sortNotesList year_desc', () => {
19 const notes = [
20 { path: 'y1.md', date: '2019-12-31' },
21 { path: 'y2.md', date: '2022-01-01' },
22 { path: 'y3.md', date: '2022-06-01' },
23 ];
24 const dk = (n) => n.date || '';
25 const out = sortNotesList(notes, 'year_desc', dk).map((n) => n.path);
26 assert.deepEqual(out, ['y3.md', 'y2.md', 'y1.md']);
27 });
28
29 test('sortProposalsList updated_desc and status_asc', () => {
30 const list = [
31 { path: 'z.md', status: 'proposed', updated_at: '2024-01-02T00:00:00Z' },
32 { path: 'a.md', status: 'approved', updated_at: '2024-01-01T00:00:00Z' },
33 { path: 'm.md', status: 'discarded', updated_at: '2024-01-03T00:00:00Z' },
34 ];
35 const u = sortProposalsList(list, 'updated_desc').map((p) => p.path);
36 assert.deepEqual(u, ['m.md', 'z.md', 'a.md']);
37 const s = sortProposalsList(list, 'status_asc').map((p) => p.path);
38 assert.deepEqual(s, ['a.md', 'm.md', 'z.md']);
39 });
File History 2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd feat(calendar): enforce agent context tiers in retrieval AP… Human minor 1 day ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6 docs: accept Calendar Events v0 spec with Phase 0 security … Human 2 days ago