"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = require("node:test");
const strict_1 = __importDefault(require("node:assert/strict"));
const clickup_format_1 = require("../providers/clickup-format");
(0, node_test_1.describe)('clickupBlocksToMarkdown', () => {
    (0, node_test_1.it)('converts plain text blocks', () => {
        const blocks = [
            { text: 'Hello world' },
            { text: '\n' },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), 'Hello world');
    });
    (0, node_test_1.it)('converts bold text', () => {
        const blocks = [
            { text: 'This is ', attributes: {} },
            { text: 'bold', attributes: { bold: true } },
            { text: ' text\n' },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), 'This is **bold** text');
    });
    (0, node_test_1.it)('converts italic text', () => {
        const blocks = [
            { text: 'This is ', attributes: {} },
            { text: 'italic', attributes: { italic: true } },
            { text: '\n' },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), 'This is *italic*');
    });
    (0, node_test_1.it)('converts inline code', () => {
        const blocks = [
            { text: 'Use ' },
            { text: 'npm install', attributes: { code: true } },
            { text: '\n' },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), 'Use `npm install`');
    });
    (0, node_test_1.it)('converts links', () => {
        const blocks = [
            { text: 'Click ' },
            { text: 'here', attributes: { link: 'https://example.com' } },
            { text: '\n' },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), 'Click [here](https://example.com)');
    });
    (0, node_test_1.it)('converts bullet list', () => {
        const blocks = [
            { text: 'First item' },
            { text: '\n', attributes: { list: { list: 'bullet' } } },
            { text: 'Second item' },
            { text: '\n', attributes: { list: { list: 'bullet' } } },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), '- First item\n- Second item');
    });
    (0, node_test_1.it)('converts ordered list', () => {
        const blocks = [
            { text: 'First' },
            { text: '\n', attributes: { list: { list: 'ordered' } } },
            { text: 'Second' },
            { text: '\n', attributes: { list: { list: 'ordered' } } },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), '1. First\n2. Second');
    });
    (0, node_test_1.it)('converts checklist', () => {
        const blocks = [
            { text: 'Done task' },
            { text: '\n', attributes: { list: { list: 'checked' } } },
            { text: 'Pending task' },
            { text: '\n', attributes: { list: { list: 'unchecked' } } },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), '- [x] Done task\n- [ ] Pending task');
    });
    (0, node_test_1.it)('converts code block', () => {
        const blocks = [
            { text: 'const x = 1;' },
            { text: '\n', attributes: { 'code-block': 'javascript' } },
            { text: 'const y = 2;' },
            { text: '\n', attributes: { 'code-block': 'javascript' } },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), '```\nconst x = 1;\nconst y = 2;\n```');
    });
    (0, node_test_1.it)('handles code-block with nested object format', () => {
        const blocks = [
            { text: 'hello()' },
            { text: '\n', attributes: { 'code-block': { 'code-block': 'plain' } } },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), '```\nhello()\n```');
    });
    (0, node_test_1.it)('handles mixed content', () => {
        const blocks = [
            { text: 'Title', attributes: { bold: true } },
            { text: '\n' },
            { text: 'Item A' },
            { text: '\n', attributes: { list: { list: 'bullet' } } },
            { text: 'Item B' },
            { text: '\n', attributes: { list: { list: 'bullet' } } },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), '**Title**\n- Item A\n- Item B');
    });
    (0, node_test_1.it)('returns empty string for empty/null input', () => {
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)([]), '');
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(null), '');
    });
    (0, node_test_1.it)('handles list attribute as plain string', () => {
        const blocks = [
            { text: 'item' },
            { text: '\n', attributes: { list: 'bullet' } },
        ];
        strict_1.default.equal((0, clickup_format_1.clickupBlocksToMarkdown)(blocks), '- item');
    });
});
(0, node_test_1.describe)('markdownToClickupBlocks', () => {
    (0, node_test_1.it)('converts plain text', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('Hello world');
        strict_1.default.deepEqual(blocks, [
            { text: 'Hello world' },
            { text: '\n' },
        ]);
    });
    (0, node_test_1.it)('converts bold text', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('This is **bold** text');
        strict_1.default.deepEqual(blocks, [
            { text: 'This is ' },
            { text: 'bold', attributes: { bold: true } },
            { text: ' text' },
            { text: '\n' },
        ]);
    });
    (0, node_test_1.it)('converts italic text', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('This is *italic* text');
        strict_1.default.deepEqual(blocks, [
            { text: 'This is ' },
            { text: 'italic', attributes: { italic: true } },
            { text: ' text' },
            { text: '\n' },
        ]);
    });
    (0, node_test_1.it)('converts inline code', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('Use `npm install` now');
        strict_1.default.deepEqual(blocks, [
            { text: 'Use ' },
            { text: 'npm install', attributes: { code: true } },
            { text: ' now' },
            { text: '\n' },
        ]);
    });
    (0, node_test_1.it)('converts links', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('Click [here](https://example.com)');
        strict_1.default.deepEqual(blocks, [
            { text: 'Click ' },
            { text: 'here', attributes: { link: 'https://example.com' } },
            { text: '\n' },
        ]);
    });
    (0, node_test_1.it)('converts bullet list', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('- First\n- Second');
        strict_1.default.deepEqual(blocks, [
            { text: 'First' },
            { text: '\n', attributes: { list: { list: 'bullet' } } },
            { text: 'Second' },
            { text: '\n', attributes: { list: { list: 'bullet' } } },
        ]);
    });
    (0, node_test_1.it)('converts ordered list', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('1. First\n2. Second');
        strict_1.default.deepEqual(blocks, [
            { text: 'First' },
            { text: '\n', attributes: { list: { list: 'ordered' } } },
            { text: 'Second' },
            { text: '\n', attributes: { list: { list: 'ordered' } } },
        ]);
    });
    (0, node_test_1.it)('converts checklist', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('- [x] Done\n- [ ] Todo');
        strict_1.default.deepEqual(blocks, [
            { text: 'Done' },
            { text: '\n', attributes: { list: { list: 'checked' } } },
            { text: 'Todo' },
            { text: '\n', attributes: { list: { list: 'unchecked' } } },
        ]);
    });
    (0, node_test_1.it)('converts code block', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('```js\nconst x = 1;\n```');
        strict_1.default.deepEqual(blocks, [
            { text: 'const x = 1;' },
            { text: '\n', attributes: { 'code-block': { 'code-block': 'js' } } },
        ]);
    });
    (0, node_test_1.it)('converts headings to bold', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('## My Heading');
        strict_1.default.deepEqual(blocks, [
            { text: 'My Heading', attributes: { bold: true } },
            { text: '\n' },
        ]);
    });
    (0, node_test_1.it)('handles empty lines as paragraph breaks', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('Line 1\n\nLine 2');
        strict_1.default.deepEqual(blocks, [
            { text: 'Line 1' },
            { text: '\n' },
            { text: '\n' },
            { text: 'Line 2' },
            { text: '\n' },
        ]);
    });
    (0, node_test_1.it)('handles inline formatting inside list items', () => {
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)('- **bold** item');
        strict_1.default.deepEqual(blocks, [
            { text: 'bold', attributes: { bold: true } },
            { text: ' item' },
            { text: '\n', attributes: { list: { list: 'bullet' } } },
        ]);
    });
});
(0, node_test_1.describe)('round-trip conversion', () => {
    (0, node_test_1.it)('preserves plain text through round-trip', () => {
        const md = 'Hello world';
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)(md);
        const result = (0, clickup_format_1.clickupBlocksToMarkdown)(blocks);
        strict_1.default.equal(result, md);
    });
    (0, node_test_1.it)('preserves bullet list through round-trip', () => {
        const md = '- Item A\n- Item B\n- Item C';
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)(md);
        const result = (0, clickup_format_1.clickupBlocksToMarkdown)(blocks);
        strict_1.default.equal(result, md);
    });
    (0, node_test_1.it)('preserves ordered list through round-trip', () => {
        const md = '1. First\n2. Second\n3. Third';
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)(md);
        const result = (0, clickup_format_1.clickupBlocksToMarkdown)(blocks);
        strict_1.default.equal(result, md);
    });
    (0, node_test_1.it)('preserves bold and italic through round-trip', () => {
        const md = 'This is **bold** and *italic* text';
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)(md);
        const result = (0, clickup_format_1.clickupBlocksToMarkdown)(blocks);
        strict_1.default.equal(result, md);
    });
    (0, node_test_1.it)('preserves inline code through round-trip', () => {
        const md = 'Run `npm test` now';
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)(md);
        const result = (0, clickup_format_1.clickupBlocksToMarkdown)(blocks);
        strict_1.default.equal(result, md);
    });
    (0, node_test_1.it)('preserves links through round-trip', () => {
        const md = 'Visit [docs](https://docs.example.com) for info';
        const blocks = (0, clickup_format_1.markdownToClickupBlocks)(md);
        const result = (0, clickup_format_1.clickupBlocksToMarkdown)(blocks);
        strict_1.default.equal(result, md);
    });
});
//# sourceMappingURL=clickup-format.test.js.map