@ic-wallet-kit/hpl
Version:
Ic middleware wallet HPL protocol
73 lines (72 loc) • 3.25 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const mockLogger_1 = require("../../../__tests_utils/mockLogger");
const seedToIdentity_1 = require("../../../__tests_utils/seedToIdentity");
const hplAccountCacheDataHandler_1 = require("../../../internalHandlers/cacheDataHandlers/hplAccountCacheDataHandler/hplAccountCacheDataHandler");
const repositories_1 = require("../../../repositories");
const service_1 = require("../../../service");
const common_1 = require("@ic-wallet-kit/common");
describe("Unit HplAccountCacheDataHandler tests", () => {
const testData = [
{
name: "get accounts from canister",
input: {
loadType: common_1.LoadType.Full
},
data: {
cacheData: undefined,
},
result: common_1.FormResult.success({
accountLastId: BigInt(5),
accounts: [
{
accountId: BigInt(0),
accountType: {
ft: BigInt(0),
},
},
{
accountId: BigInt(1),
accountType: {
ft: BigInt(0),
},
},
{
accountId: BigInt(2),
accountType: {
ft: BigInt(5),
},
},
{
accountId: BigInt(3),
accountType: {
ft: BigInt(0),
},
},
{
accountId: BigInt(4),
accountType: {
ft: BigInt(17),
},
},
],
})
},
];
for (let test of testData) {
it(test.name, async () => {
jest.restoreAllMocks();
const identifierService = (0, seedToIdentity_1.seedToIdentifierService)("a");
const canisterService = new service_1.CanisterService("rqx66-eyaaa-aaaap-aaona-cai", "lpwlq-2iaaa-aaaap-ab2vq-cai", "n65ik-oqaaa-aaaag-acb4q-cai");
const cacheRepository = new repositories_1.HplDataCacheRepository();
cacheRepository.getHplDataByCanisterId = jest.fn().mockReturnValue(test.data.cacheData);
cacheRepository.setHplData = jest.fn().mockReturnValue(undefined);
//identifierService.getAgent = jest.fn().mockReturnValue(identifierService.getAgent())
//identifierService.getPrincipal = jest.fn().mockReturnValue(Principal.fromText("gjcgk-x4xlt-6dzvd-q3mrr-pvgj5-5bjoe-beege-n4b7d-7hna5-pa5uq-5qe"))
const logger = new mockLogger_1.MockLogger();
const hplAccountCacheDataHandler = new hplAccountCacheDataHandler_1.HplAccountCacheDataHandler(logger, identifierService, cacheRepository, canisterService);
const result = await hplAccountCacheDataHandler.handle(test.input);
expect(result).toEqual(test.result);
}, 10000);
}
});