"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
const chai_1 = require("chai");
const core_bentley_1 = require("@itwin/core-bentley");
const core_frontend_1 = require("@itwin/core-frontend");
const TestContext_1 = require("./setup/TestContext");
describe("DevTools", () => {
    let iModel;
    let devTools;
    before(async function () {
        const testContext = await TestContext_1.TestContext.instance();
        if (!testContext.settings.runDevToolsRpcTests)
            this.skip();
        iModel = await testContext.iModelWithChangesets.getConnection();
        devTools = core_frontend_1.DevTools.connectToBackendInstance(iModel.getRpcProps());
    });
    it("can fetch stats from backend", async () => {
        const stats = await devTools.stats();
        chai_1.assert.isDefined(stats);
        chai_1.assert.isDefined(stats.os);
        chai_1.assert.isDefined(stats.process);
    });
    it("can ping backend", async () => {
        const ret = await devTools.ping(10);
        chai_1.assert.isDefined(ret.avg);
        chai_1.assert.isDefined(ret.max);
        chai_1.assert.isDefined(ret.min);
    });
    it("can set log level", async () => {
        const loggerCategory = "test-category";
        const firstLevel = core_bentley_1.LogLevel.Info;
        await devTools.setLogLevel(loggerCategory, firstLevel);
        const secondLevel = core_bentley_1.LogLevel.Warning;
        const actualFirstLevel = await devTools.setLogLevel(loggerCategory, secondLevel);
        chai_1.assert.equal(actualFirstLevel, firstLevel);
        const thirdLevel = core_bentley_1.LogLevel.Error;
        const acutalSecondLevel = await devTools.setLogLevel(loggerCategory, thirdLevel);
        chai_1.assert.equal(acutalSecondLevel, secondLevel);
    });
    it("can get the versions", async () => {
        const versions = await devTools.versions();
        chai_1.assert.isDefined(versions.application);
        chai_1.assert.isDefined(versions.iTwinJs);
    });
});
//# sourceMappingURL=DevToolsRpc.test.js.map