"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Red Hat. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
const testHelper_1 = require("./utils/testHelper");
const serviceSetup_1 = require("./utils/serviceSetup");
const verifyError_1 = require("./utils/verifyError");
const assert_1 = __importDefault(require("assert"));
// Defines a Mocha test describe to group tests of similar kind together
describe('Custom Tag tests Tests', () => {
    let languageSettingsSetup;
    let languageService;
    let validationHandler;
    before(() => {
        languageSettingsSetup = new serviceSetup_1.ServiceSetup().withValidate();
        const { languageService: langService, validationHandler: valHandler } = (0, testHelper_1.setupLanguageService)(languageSettingsSetup.languageSettings);
        validationHandler = valHandler;
        languageService = langService;
    });
    function parseSetup(content, customTags) {
        const testTextDocument = (0, testHelper_1.setupTextDocument)(content);
        languageSettingsSetup.languageSettings.customTags = customTags;
        languageService.configure(languageSettingsSetup.languageSettings);
        return validationHandler.validateTextDocument(testTextDocument);
    }
    describe('Test that validation does not throw errors', function () {
        it('Custom Tags without type not specified', async () => {
            const content = 'scalar_test: !Test test_example';
            const result = await parseSetup(content, ['!Test']);
            assert_1.default.equal(result.length, 0);
        });
        it('Custom Tags with one type', async () => {
            const content = 'resolvers: !Ref\n  - test';
            const result = await parseSetup(content, ['!Ref sequence']);
            assert_1.default.equal(result.length, 0);
        });
        it('Custom Tags with multiple types', async () => {
            const content = 'resolvers: !Ref\n  - test';
            const result = await parseSetup(content, ['!Ref sequence', '!Ref mapping', '!Ref scalar']);
            assert_1.default.equal(result.length, 0);
        });
        it('Custom Tags with input and return types', async () => {
            const content = 'resolvers: !Ref\n  - test';
            const result = await parseSetup(content, ['!Ref sequence:string']);
            assert_1.default.equal(result.length, 0);
        });
        it('Allow multiple different custom tag types with different use', async () => {
            const content = '!test\nhello: !test\n  world';
            const result = await parseSetup(content, ['!test scalar', '!test mapping']);
            assert_1.default.equal(result.length, 0);
        });
        it('Allow multiple different custom tag types with multiple different uses', async () => {
            const content = '!test\nhello: !test\n  world\nsequence: !ref\n  - item1';
            const result = await parseSetup(content, ['!test scalar', '!test mapping', '!ref sequence', '!ref mapping']);
            assert_1.default.equal(result.length, 0);
        });
    });
    describe('Test that validation does throw errors', function () {
        it('Error when custom tag is not available', async () => {
            const content = '!test';
            const result = await parseSetup(content, []);
            assert_1.default.equal(result.length, 1);
            assert_1.default.deepEqual(result[0], (0, verifyError_1.createExpectedError)('Unresolved tag: !test', 0, 0, 0, 5));
        });
    });
});
//# sourceMappingURL=customTags.test.js.map