hub-list-sort.test.mjs
39 lines 1.6 KB
Raw
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor ⚠ breaking 13 days 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 4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor 13 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b fix(7C-L1b): route hosted delegation proposals through cani… Human minor 32 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91 fix: repair endpoint now sets has_active_subscription when … Human minor 52 days ago