/*
 * @jest-environment jsdom
 */
import { Detector } from "./Detector";
import westmint from "./specs/westend-westmint.json";
import westend2 from "./specs/westend.json";
describe("Initialize Detector without extension", () => {
    const timeout = 15000;
    const extTimeout = 35000;
    test('Should connect with known chain "westend".', async () => {
        const detect = new Detector("test-uapp");
        const api = await detect.connect("westend");
        expect(api).toBeTruthy();
        await api.disconnect();
    }, timeout);
    test('Should connect with known chain "polkadot".', async () => {
        const detect = new Detector("test-uapp");
        const api = await detect.connect("polkadot");
        expect(api).toBeTruthy();
        await api.disconnect();
    }, extTimeout);
    test("Should connect with known chain westend, no chainSpecs and options", async () => {
        const chainName = "westend";
        const detect = new Detector("test-uapp");
        const options = {};
        const api = await detect.connect(chainName, undefined, options);
        expect(api).toBeTruthy();
        await api.disconnect();
    }, extTimeout);
    test('Should connect with known chain "kusama".', async () => {
        const detect = new Detector("test-uapp");
        const api = await detect.connect("kusama");
        expect(api).toBeTruthy();
        await api.disconnect();
    }, extTimeout);
    test("Should connect with unknown chain westend2 and chainSpecs.", async () => {
        const chainSpec = JSON.stringify(westend2);
        const detect = new Detector("test-uapp");
        const api = await detect.connect(chainSpec);
        expect(api).toBeTruthy();
        await api.disconnect();
    }, extTimeout);
    test("Should NOT connect with unknown chain westend2 and without chainSpecs.", () => {
        const chainName = "westend";
        const detect = new Detector("test-uapp");
        void expect(detect.connect(chainName)).rejects.toThrow(`No known Chain was detected and no chainSpec was provided. Either give a known chain name ('polkadot', 'kusama', 'westend') or provide valid chainSpecs.`);
    }, timeout);
    test('Should connect with known chain "westend" and parachain "westmint".', async () => {
        const detect = new Detector("test-uapp");
        const api = await detect.connect("westend", JSON.stringify(westmint));
        expect(api).toBeTruthy();
        await api.disconnect();
    }, timeout);
});
//# sourceMappingURL=Detector.test.js.map