"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 });
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) IBM Corp. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
const chai_1 = require("chai");
const sinon = __importStar(require("sinon"));
const schemaSelectionHandlers_1 = require("../src/languageserver/handlers/schemaSelectionHandlers");
const yamlSchemaService_1 = require("../src/languageservice/services/yamlSchemaService");
const yamlSettings_1 = require("../src/yamlSettings");
const testHelper_1 = require("./utils/testHelper");
describe('unexpected meta schema', () => {
    const sandbox = sinon.createSandbox();
    const connection = {};
    let service;
    let requestServiceMock;
    beforeEach(() => {
        requestServiceMock = sandbox.fake.resolves('{ "$schema": "https://example.com/my-custom-meta-schema/v1", "type": "object" }');
        service = new yamlSchemaService_1.YAMLSchemaService(requestServiceMock);
        connection.client = {};
        const onRequest = sandbox.fake();
        connection.onRequest = onRequest;
    });
    afterEach(() => {
        sandbox.restore();
    });
    it('should not throw when a non-standard meta schema is used', async () => {
        service.registerExternalSchema('https://some.com/some.json', ['*.yaml'], undefined, 'Schema name', 'Schema description');
        const settings = new yamlSettings_1.SettingsState();
        const testTextDocument = (0, testHelper_1.setupSchemaIDTextDocument)('');
        settings.documents = new yamlSettings_1.TextDocumentTestManager();
        settings.documents.set(testTextDocument);
        const selection = new schemaSelectionHandlers_1.JSONSchemaSelection(service, settings, connection);
        try {
            await selection.getSchemas(testTextDocument.uri);
        }
        catch (e) {
            chai_1.assert.fail('Unexpected exception: ' + e);
        }
    });
});
//# sourceMappingURL=invalid-metaschema.test.js.map