test: unit and end-to-end suites
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
27fafa0bcd
commit
9b00e21c44
49 files changed
+6694
-1
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { parseBoard, boardToMd, boardFromMarkdown, defaultBoard, isBoard } from '../src/lib/kanban.js';
|
||||
|
||||
const OBSIDIAN = `## To do
|
||||
|
||||
- [ ] Write **intro** with [[Plan]]
|
||||
second line
|
||||
- [ ] Two
|
||||
|
||||
|
||||
## Done
|
||||
|
||||
**Complete**
|
||||
- [x] Old
|
||||
|
||||
|
||||
## Empty
|
||||
|
||||
|
||||
%% kanban:settings
|
||||
\`\`\`
|
||||
{"kanban-plugin":"basic"}
|
||||
\`\`\`
|
||||
%%
|
||||
`;
|
||||
|
||||
test('an Obsidian Kanban board survives a round trip', () => {
|
||||
const b = parseBoard(OBSIDIAN);
|
||||
assert.deepEqual(b.columns.map((c) => [c.title, c.cards.length]), [['To do', 2], ['Done', 1], ['Empty', 0]]);
|
||||
assert.equal(b.columns[0].cards[0].text, 'Write **intro** with [[Plan]]\nsecond line');
|
||||
assert.equal(b.columns[1].cards[0].done, true);
|
||||
assert.deepEqual(b.columns[1].extra, ['**Complete**']);
|
||||
assert.match(b.tail, /^%% kanban:settings/);
|
||||
assert.equal(boardToMd(b), OBSIDIAN);
|
||||
});
|
||||
|
||||
test('boards are made from pages and from scratch', () => {
|
||||
assert.equal(isBoard({ 'kanban-plugin': 'basic' }), true);
|
||||
assert.equal(isBoard({}), false);
|
||||
assert.equal(boardToMd(defaultBoard()), '## To do\n\n\n## Doing\n\n\n## Done\n');
|
||||
const b = boardFromMarkdown('Loose idea\n\n# Week\n\n- [x] done thing\n- bullet\n\n---\n\nPara with [[Link]]\n');
|
||||
assert.deepEqual(b.columns.map((c) => [c.title, c.cards.map((k) => k.text + (k.done ? ' ✓' : ''))]), [
|
||||
['To do', ['Loose idea']],
|
||||
['Week', ['done thing ✓', 'bullet', 'Para with [[Link]]']]
|
||||
]);
|
||||
assert.equal(boardFromMarkdown('').columns.length, 3);
|
||||
});
|
||||
Reference in new issue
Block a user