/**
 * @author Louis-Dominique Dubeau
 * @license MPL 2.0
 * @copyright Mangalam Research Center for Buddhist Languages
 */
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
define(["require", "exports", "@wedxml/common/browsers", "wed/convert", "../util", "../wed-test-util"], function (require, exports, browsers, convert, util_1, wed_test_util_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    browsers = __importStar(browsers);
    convert = __importStar(convert);
    const assert = chai.assert;
    describe("convert", () => {
        let parser;
        let provider;
        before(() => {
            parser = new DOMParser();
            provider = new util_1.DataProvider(`${wed_test_util_1.dataPath}/convert_test_data/`);
        });
        function makeTest(name, differsOnIE = false) {
            const convertedName = name.replace(/ /g, "-");
            const sourcePath = `${convertedName}.xml`;
            // If the test differs on IE and we are on IE, then add -ie to the basename.
            const ie = differsOnIE && browsers.MSIE;
            const expectedPath = `${convertedName + (ie ? "-ie" : "")}.html`;
            describe("", () => {
                let source;
                let expected;
                before(() => Promise.all([
                    provider.getText(sourcePath).then((data) => {
                        source = data;
                    }),
                    provider.getText(expectedPath).then((data) => {
                        expected = data;
                    })
                ]));
                it(name, () => {
                    const root = parser.parseFromString(source, "application/xml")
                        .documentElement;
                    const html = convert.toHTMLTree(window.document, root);
                    // The reason this does not produce a diff seems to be that Mocha's HTML
                    // reporter does not support diffs.
                    assert.equal(`${html.outerHTML}\n`, expected);
                });
            });
        }
        // tslint:disable:mocha-no-side-effect-code
        makeTest("should convert xml to html");
        makeTest("should encode name prefixes", true);
        makeTest("should encode dashes in attribute names");
        makeTest("should encode namespace changes", true);
        // tslint:enable:mocha-no-side-effect-code
    });
});
//# sourceMappingURL=convert-test.js.map