|
| 1 | +import * as assert from 'assert'; |
| 2 | +import * as Path from 'path'; |
| 3 | +import { inferType, InferTypeContext } from '../../journal/paths'; |
| 4 | +import { JournalPageType } from '../../model/config'; |
| 5 | + |
| 6 | +suite('inferType — classification', () => { |
| 7 | + const ctx: InferTypeContext = { extension: '.md' }; |
| 8 | + |
| 9 | + suite('attachment', () => { |
| 10 | + test('extension mismatch → attachement', () => { |
| 11 | + const entry = Path.parse('/base/2026/05/2026-05-18.txt'); |
| 12 | + assert.strictEqual(inferType(entry, ctx), JournalPageType.attachement); |
| 13 | + }); |
| 14 | + |
| 15 | + test('no extension → attachement', () => { |
| 16 | + const entry = Path.parse('/base/2026/05/2026-05-18'); |
| 17 | + assert.strictEqual(inferType(entry, ctx), JournalPageType.attachement); |
| 18 | + }); |
| 19 | + }); |
| 20 | + |
| 21 | + suite('entry', () => { |
| 22 | + test('digits-only name → entry', () => { |
| 23 | + const entry = Path.parse('/base/2026/05/20260518.md'); |
| 24 | + assert.strictEqual(inferType(entry, ctx), JournalPageType.entry); |
| 25 | + }); |
| 26 | + |
| 27 | + test('digits with hyphens → entry', () => { |
| 28 | + const entry = Path.parse('/base/2026/05/2026-05-18.md'); |
| 29 | + assert.strictEqual(inferType(entry, ctx), JournalPageType.entry); |
| 30 | + }); |
| 31 | + |
| 32 | + test('digits with underscores → entry', () => { |
| 33 | + const entry = Path.parse('/base/2026/05/2026_05_18.md'); |
| 34 | + assert.strictEqual(inferType(entry, ctx), JournalPageType.entry); |
| 35 | + }); |
| 36 | + |
| 37 | + test('pipe-separated name → note (pipe not a separator)', () => { |
| 38 | + // Pipe was previously a literal in the character class; now correctly excluded. |
| 39 | + const entry = Path.parse('/base/2026/05/2026|05|18.md'); |
| 40 | + assert.strictEqual(inferType(entry, ctx), JournalPageType.note); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + suite('note', () => { |
| 45 | + test('alphanumeric name → note', () => { |
| 46 | + const entry = Path.parse('/base/2026/05/my-note.md'); |
| 47 | + assert.strictEqual(inferType(entry, ctx), JournalPageType.note); |
| 48 | + }); |
| 49 | + |
| 50 | + test('name with letters and digits → note', () => { |
| 51 | + const entry = Path.parse('/base/2026/05/meeting2026.md'); |
| 52 | + assert.strictEqual(inferType(entry, ctx), JournalPageType.note); |
| 53 | + }); |
| 54 | + }); |
| 55 | +}); |
0 commit comments