"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
const documents_1 = require("../../../src/lib/documents");
const getFoldingRanges_1 = require("../../../src/plugins/html/getFoldingRanges");
const assert = __importStar(require("assert"));
function assertRanges(lines, expected, message) {
    const document = documents_1.Document.createForTest('file://foo/bar.json', lines.join('\n'));
    const actual = (0, getFoldingRanges_1.getFoldingRanges)(document, {
        lineFoldingOnly: true
    });
    let actualRanges = [];
    for (let i = 0; i < actual.length; i++) {
        actualRanges[i] = r(actual[i].startLine, actual[i].endLine, actual[i].kind);
    }
    actualRanges = actualRanges.sort((r1, r2) => r1.startLine - r2.startLine);
    assert.deepEqual(actualRanges, expected, message);
}
function r(startLine, endLine, kind) {
    return { startLine, endLine, kind };
}
describe('getFoldingRanges mates vscode-html-languageservice', () => {
    it('Fold one level', () => {
        const input = [/*0*/ '<html>', /*1*/ 'Hello', /*2*/ '</html>'];
        assertRanges(input, [r(0, 1)]);
    });
    it('Fold two level', () => {
        const input = [
            /*0*/ '<html>',
            /*1*/ '<head>',
            /*2*/ 'Hello',
            /*3*/ '</head>',
            /*4*/ '</html>'
        ];
        assertRanges(input, [r(0, 3), r(1, 2)]);
    });
    it('Fold siblings', () => {
        const input = [
            /*0*/ '<html>',
            /*1*/ '<head>',
            /*2*/ 'Head',
            /*3*/ '</head>',
            /*4*/ '<body class="f">',
            /*5*/ 'Body',
            /*6*/ '</body>',
            /*7*/ '</html>'
        ];
        assertRanges(input, [r(0, 6), r(1, 2), r(4, 5)]);
    });
    it('Fold self-closing tags', () => {
        const input = [
            /*0*/ '<div>',
            /*1*/ '<a href="top"/>',
            /*2*/ '<img src="s">',
            /*3*/ '<br/>',
            /*4*/ '<br>',
            /*5*/ '<img class="c"',
            /*6*/ '     src="top"',
            /*7*/ '>',
            /*8*/ '</div>'
        ];
        assertRanges(input, [r(0, 7), r(5, 6)]);
    });
    it('Fold comment', () => {
        const input = [
            /*0*/ '<!--',
            /*1*/ ' multi line',
            /*2*/ '-->',
            /*3*/ '<!-- some stuff',
            /*4*/ ' some more stuff -->'
        ];
        assertRanges(input, [r(0, 2, 'comment'), r(3, 4, 'comment')]);
    });
    it('Fold regions', () => {
        const input = [
            /*0*/ '<!-- #region -->',
            /*1*/ '<!-- #region -->',
            /*2*/ '<!-- #endregion -->',
            /*3*/ '<!-- #endregion -->'
        ];
        assertRanges(input, [r(0, 3, 'region'), r(1, 2, 'region')]);
    });
    it('Fold incomplete', () => {
        const input = [
            /*0*/ '<body>',
            /*1*/ '<div></div>',
            /*2*/ 'Hello',
            /*3*/ '</div>',
            /*4*/ '</body>'
        ];
        assertRanges(input, [r(0, 3)]);
    });
    it('Fold incomplete 2', () => {
        const input = [/*0*/ '<be><div>', /*1*/ '<!-- #endregion -->', /*2*/ '</div>'];
        assertRanges(input, [r(0, 1)]);
    });
    it('Fold intersecting region', () => {
        const input = [
            /*0*/ '<body>',
            /*1*/ '<!-- #region -->',
            /*2*/ 'Hello',
            /*3*/ '<div></div>',
            /*4*/ '</body>',
            /*5*/ '<!-- #endregion -->'
        ];
        assertRanges(input, [r(0, 3)]);
    });
    it('Fold intersecting region 2', () => {
        const input = [
            /*0*/ '<!-- #region -->',
            /*1*/ '<body>',
            /*2*/ 'Hello',
            /*3*/ '<!-- #endregion -->',
            /*4*/ '<div></div>',
            /*5*/ '</body>'
        ];
        assertRanges(input, [r(0, 3, 'region')]);
    });
});
//# sourceMappingURL=getFoldingRange.test.js.map