export-note-record-to-content.test.mjs
40 lines 1.4 KB
Raw
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor ⚠ breaking 10 days ago
1 import { test, describe } from 'node:test';
2 import assert from 'node:assert/strict';
3 import { exportNoteRecordToContent, exportNoteToContent } from '../lib/export.mjs';
4 import fs from 'node:fs';
5 import os from 'node:os';
6 import path from 'node:path';
7
8 describe('exportNoteRecordToContent', () => {
9 test('produces md with yaml frontmatter and source_notes', () => {
10 const { content, filename } = exportNoteRecordToContent(
11 { body: 'Hello', frontmatter: { title: 'T', tags: ['a'] } },
12 'inbox/x.md',
13 { format: 'md' },
14 );
15 assert.equal(filename, 'x.md');
16 assert.ok(content.includes('---\n'));
17 assert.ok(content.includes('source_notes'));
18 assert.ok(content.includes('Hello'));
19 });
20
21 test('exportNoteToContent delegates to same shape as record export', () => {
22 const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'kt-exp-'));
23 const rel = 'a/b.md';
24 const abs = path.join(dir, rel);
25 fs.mkdirSync(path.dirname(abs), { recursive: true });
26 fs.writeFileSync(
27 abs,
28 '---\ntitle: One\ntags:\n - t\n---\nBody here\n',
29 'utf8',
30 );
31 const a = exportNoteToContent(dir, rel, { format: 'md' });
32 const b = exportNoteRecordToContent(
33 { body: 'Body here', frontmatter: { title: 'One', tags: ['t'] } },
34 rel,
35 { format: 'md' },
36 );
37 assert.equal(a.filename, b.filename);
38 assert.equal(a.content.replace(/\r?\n/g, '\n').trimEnd(), b.content.replace(/\r?\n/g, '\n').trimEnd());
39 });
40 });
File History 4 commits
sha256:b5f647cb9c409f563d4671fe3fc05ddea01fabfed9b41fc11cb923588e1c1baf mirror: GitHub Phase A durable MCP OAuth (#270) Human minor 10 days ago
sha256:d8c648b20a4d53b2673c5c082ee7edfa7b2fc9b11080832da1f38807b6bf940b fix(7C-L1b): route hosted delegation proposals through cani… Human minor 30 days ago
sha256:2827ba9e7632a4b141c50caf1e8f7d77abbc3515be20e7465f2bccb0ac4edf91 fix: repair endpoint now sets has_active_subscription when … Human minor 50 days ago