hub-gateway-note-facets.test.mjs
sha256:6a102aafafdfe7e70a24f4e59740200f0ee713ce7915f1b53e9d4ba5ee8b4410
Initial Muse snapshot
Human
48 days ago
| 1 | import { describe, it } from 'node:test'; |
| 2 | import assert from 'node:assert/strict'; |
| 3 | import { |
| 4 | materializeListFrontmatter, |
| 5 | deriveFacetsFromCanisterNotes, |
| 6 | } from '../hub/gateway/note-facets.mjs'; |
| 7 | |
| 8 | describe('note-facets', () => { |
| 9 | it('materializeListFrontmatter parses JSON string', () => { |
| 10 | const fm = materializeListFrontmatter('{"tags":"a,b","project":"p1"}'); |
| 11 | assert.equal(fm.project, 'p1'); |
| 12 | assert.ok(Array.isArray(fm.tags) === false); |
| 13 | }); |
| 14 | |
| 15 | it('deriveFacetsFromCanisterNotes collects folders tags projects', () => { |
| 16 | const facets = deriveFacetsFromCanisterNotes([ |
| 17 | { path: 'inbox/x.md', frontmatter: '{"tags":"t1, t2","project":"myproj"}' }, |
| 18 | { path: 'projects/launch/a.md', frontmatter: '{}' }, |
| 19 | ]); |
| 20 | assert.ok(facets.folders.includes('inbox')); |
| 21 | assert.ok(facets.folders.includes('projects')); |
| 22 | assert.ok(facets.tags.includes('t1')); |
| 23 | assert.ok(facets.tags.includes('t2')); |
| 24 | assert.ok(facets.projects.includes('myproj')); |
| 25 | }); |
| 26 | |
| 27 | it('empty string frontmatter yields empty facets aside from folder from path', () => { |
| 28 | const facets = deriveFacetsFromCanisterNotes([{ path: 'inbox/y.md', frontmatter: '{}' }]); |
| 29 | assert.equal(facets.projects.length, 0); |
| 30 | assert.equal(facets.tags.length, 0); |
| 31 | assert.deepEqual(facets.folders, ['inbox']); |
| 32 | }); |
| 33 | }); |
File History
1 commit
sha256:6a102aafafdfe7e70a24f4e59740200f0ee713ce7915f1b53e9d4ba5ee8b4410
Initial Muse snapshot
Human
48 days ago