"use strict";
// SPDX-License-Identifier: Apache-2.0
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const tsyringe_1 = require("tsyringe");
const NetworkService_1 = __importDefault(require("./NetworkService")); // Adjust path as needed
describe("NetworkService", () => {
    let networkService;
    let mockProps;
    beforeEach(() => {
        jest.clearAllMocks();
        tsyringe_1.container.clearInstances();
        mockProps = {
            environment: {},
            mirrorNode: {},
            rpcNode: {},
            consensusNodes: "consensus-node-1,consensus-node-2",
            configuration: {},
        };
        tsyringe_1.container.register("NetworkProps", { useValue: mockProps });
        networkService = tsyringe_1.container.resolve(NetworkService_1.default);
    });
    describe("constructor", () => {
        it("should initialize with provided NetworkProps", () => {
            expect(networkService.environment).toBe(mockProps.environment);
            expect(networkService.mirrorNode).toBe(mockProps.mirrorNode);
            expect(networkService.rpcNode).toBe(mockProps.rpcNode);
            expect(networkService.consensusNodes).toBe(mockProps.consensusNodes);
            expect(networkService.configuration).toBe(mockProps.configuration);
        });
        it("should initialize with undefined props if none provided", () => {
            tsyringe_1.container.clearInstances();
            tsyringe_1.container.register("NetworkProps", {
                useValue: {
                    environment: undefined,
                    mirrorNode: undefined,
                    rpcNode: undefined,
                    consensusNodes: undefined,
                    configuration: undefined,
                },
            });
            const service = tsyringe_1.container.resolve(NetworkService_1.default);
            expect(service.environment).toBeUndefined();
            expect(service.mirrorNode).toBeUndefined();
            expect(service.rpcNode).toBeUndefined();
            expect(service.consensusNodes).toBeUndefined();
            expect(service.configuration).toBeUndefined();
        });
        it("should be a singleton", () => {
            const service1 = tsyringe_1.container.resolve(NetworkService_1.default);
            const service2 = tsyringe_1.container.resolve(NetworkService_1.default);
            expect(service1).toBe(service2);
        });
    });
    describe("environment getter and setter", () => {
        it("should get and set environment", () => {
            const newEnvironment = {};
            networkService.environment = newEnvironment;
            const result = networkService.environment;
            expect(result).toBe(newEnvironment);
        });
    });
    describe("mirrorNode getter and setter", () => {
        it("should get and set mirrorNode", () => {
            const newMirrorNode = {};
            networkService.mirrorNode = newMirrorNode;
            const result = networkService.mirrorNode;
            expect(result).toBe(newMirrorNode);
        });
    });
    describe("rpcNode getter and setter", () => {
        it("should get and set rpcNode", () => {
            const newRpcNode = {};
            networkService.rpcNode = newRpcNode;
            const result = networkService.rpcNode;
            expect(result).toBe(newRpcNode);
        });
    });
    describe("consensusNodes getter and setter", () => {
        it("should get and set consensusNodes", () => {
            const newConsensusNodes = "new-consensus-node";
            networkService.consensusNodes = newConsensusNodes;
            const result = networkService.consensusNodes;
            expect(result).toBe(newConsensusNodes);
        });
        it("should handle undefined consensusNodes", () => {
            networkService.consensusNodes = undefined;
            const result = networkService.consensusNodes;
            expect(result).toBeUndefined();
        });
    });
    describe("configuration getter and setter", () => {
        it("should get and set configuration", () => {
            const newConfiguration = {};
            networkService.configuration = newConfiguration;
            const result = networkService.configuration;
            expect(result).toBe(newConfiguration);
        });
    });
});
