"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const ts_mockito_1 = require("ts-mockito");
const models_1 = require("../../models");
const services_1 = require("../../services");
const request_1 = require("./request");
let mockConnectionService = ts_mockito_1.mock(services_1.ConnectionService);
beforeEach(() => {
    ts_mockito_1.reset(mockConnectionService);
});
describe('request', () => {
    it('getAccess', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getAccess(ts_mockito_1.instance(mockConnectionService), { refresh: false });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ refresh: false }), ts_mockito_1.deepEqual(models_1.apiConfig.requestAccess))).once();
        expect(result).toBe('result');
    }));
    it('getAddresses', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getAddresses(ts_mockito_1.instance(mockConnectionService), { refresh: false, walletid: 1 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ refresh: false, walletid: 1 }), ts_mockito_1.deepEqual(models_1.apiConfig.requestAddresses))).once();
        expect(result).toBe('result');
    }));
    it('getAllAssetClasses', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getAllAssetClasses(ts_mockito_1.instance(mockConnectionService));
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({}), ts_mockito_1.deepEqual(models_1.apiConfig.requestAllAssetClasses))).once();
        expect(result).toBe('result');
    }));
    it('getAllNamespaces', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getAllNamespaces(ts_mockito_1.instance(mockConnectionService));
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({}), ts_mockito_1.deepEqual(models_1.apiConfig.requestAllNamespaces))).once();
        expect(result).toBe('result');
    }));
    it('getContract', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getContract(ts_mockito_1.instance(mockConnectionService), { contractid: 'con', walletid: 1 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ contractid: 'con', walletid: 1 }), ts_mockito_1.deepEqual(models_1.apiConfig.requestContract))).once();
        expect(result).toBe('result');
    }));
    it('getBlock', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getBlock(ts_mockito_1.instance(mockConnectionService));
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({}), ts_mockito_1.deepEqual(models_1.apiConfig.requestBlock))).once();
        expect(result).toBe('result');
    }));
    it('getHolders', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getHolders(ts_mockito_1.instance(mockConnectionService), { namespace: 'BOE', classid: 'GBP', walletid: 1 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ namespace: 'BOE', classid: 'GBP', walletid: 1 }), ts_mockito_1.deepEqual(models_1.apiConfig.requestHolders))).once();
        expect(result).toBe('result');
    }));
    it('getHoldingsDetail', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getHoldingsDetail(ts_mockito_1.instance(mockConnectionService), { namespace: 'BOE', classid: 'GBP', walletId: 1, address: 'add' });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ namespace: 'BOE', classid: 'GBP', walletId: 1, address: 'add' }), ts_mockito_1.deepEqual(models_1.apiConfig.requestHoldingsDetail))).once();
        expect(result).toBe('result');
    }));
    it('getHoldingsDetails', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getHoldingsDetails(ts_mockito_1.instance(mockConnectionService), { namespace: 'BOE', classid: 'GBP', walletid: [1, 2] });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ namespace: 'BOE', classid: 'GBP', walletid: [1, 2] }), ts_mockito_1.deepEqual(models_1.apiConfig.requestHoldingsDetails))).once();
        expect(result).toBe('result');
    }));
    it('getHoldings', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getHoldings(ts_mockito_1.instance(mockConnectionService), { namespace: 'BOE', classid: 'GBP', walletId: 1 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ namespace: 'BOE', classid: 'GBP', walletId: 1 }), ts_mockito_1.deepEqual(models_1.apiConfig.requestHoldings))).once();
        expect(result).toBe('result');
    }));
    it('getAssetClasses', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getAssetClasses(ts_mockito_1.instance(mockConnectionService), { walletid: 1 });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ walletid: 1 }), ts_mockito_1.deepEqual(models_1.apiConfig.requestAssetClasses))).once();
        expect(result).toBe('result');
    }));
    it('getNamespace', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getNamespace(ts_mockito_1.instance(mockConnectionService), { walletid: 1, address: 'add', namespace: 'BOE' });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ walletid: 1, address: 'add', namespace: 'BOE' }), ts_mockito_1.deepEqual(models_1.apiConfig.requestNamespace))).once();
        expect(result).toBe('result');
    }));
    it('getNewAddress', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getNewAddress(ts_mockito_1.instance(mockConnectionService), { walletId: 1, creator: 'test', keyType: 'key', metadata: '' });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ walletId: 1, creator: 'test', keyType: 'key', metadata: '' }), ts_mockito_1.deepEqual(models_1.apiConfig.requestNewAddress))).once();
        expect(result).toBe('result');
    }));
    it('getPOAAttorneyDetails', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getPOAAttorneyDetails(ts_mockito_1.instance(mockConnectionService), { address: 'add' });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ address: 'add' }), ts_mockito_1.deepEqual(models_1.apiConfig.requestPOAAttorneyDetails))).once();
        expect(result).toBe('result');
    }));
    it('getPOAOwnerDetails', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getPOAOwnerDetails(ts_mockito_1.instance(mockConnectionService), { address: 'add' });
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({ address: 'add' }), ts_mockito_1.deepEqual(models_1.apiConfig.requestPOAOwnerDetails))).once();
        expect(result).toBe('result');
    }));
    it('getState', () => __awaiter(void 0, void 0, void 0, function* () {
        ts_mockito_1.when(mockConnectionService.send(ts_mockito_1.anything(), ts_mockito_1.anything())).thenResolve('result');
        const result = yield request_1.getState(ts_mockito_1.instance(mockConnectionService));
        ts_mockito_1.verify(mockConnectionService.send(ts_mockito_1.deepEqual({}), ts_mockito_1.deepEqual(models_1.apiConfig.requestState))).once();
        expect(result).toBe('result');
    }));
});
