swapable
Version:
Swapable: Automated Liquidity Pools
75 lines (74 loc) • 4.31 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This file is part of Swapable shared under AGPL-3.0
* Copyright (C) 2021 Using Blockchain Ltd, Reg No.: 12658136, United Kingdom
*
* @package Swapable
* @author Grégory Saive for Using Blockchain Ltd <greg@ubc.digital>
* @license AGPL-3.0
*/
const sinon = __importStar(require("sinon"));
const chai_1 = require("chai");
const mocha_1 = require("mocha");
const symbol_sdk_1 = require("symbol-sdk");
// internal dependencies
const index_1 = require("../../index");
const index_2 = require("../mocks/index");
const context = new index_1.Context(1, index_2.getTestAccount('operator1'), new index_1.Symbol.Reader('http://api-01.us-west-1.0941-v1.symboldev.network', index_2.getTestAccount('operator1').address.networkType, 'ACECD90E7B248E012803228ADB4424F0D966D24149B72E58987D2BF2F2AF03C4', 1573430400, new symbol_sdk_1.MosaicId('519FC24B9223E0B4'), 'DummyNodePublicKey'), new index_1.Symbol.Signer(), new index_1.TransactionParameters(1573430400, symbol_sdk_1.Deadline.create(1573430400), undefined), undefined);
const contextWithArgs = new index_1.Context(1, index_2.getTestAccount('operator1'), new index_1.Symbol.Reader('http://api-01.us-west-1.0941-v1.symboldev.network', index_2.getTestAccount('operator1').address.networkType, 'ACECD90E7B248E012803228ADB4424F0D966D24149B72E58987D2BF2F2AF03C4', 1573430400, new symbol_sdk_1.MosaicId('519FC24B9223E0B4'), 'DummyNodePublicKey'), new index_1.Symbol.Signer(), new index_1.TransactionParameters(1573430400, symbol_sdk_1.Deadline.create(1573430400), undefined), [new index_1.CommandOption('identifier', 'id')]);
mocha_1.describe('contracts/Context --->', () => {
mocha_1.describe('getInput() should', () => {
mocha_1.it('use default value given no arguments', () => {
// act
const identifier = context.getInput('identifier', 'default');
// assert
chai_1.expect(identifier).to.not.be.undefined;
chai_1.expect(identifier).to.be.equal('default');
});
mocha_1.it('use correct value given argument', () => {
// act
const identifier = contextWithArgs.getInput('identifier', 'default');
// assert
chai_1.expect(identifier).to.not.be.undefined;
chai_1.expect(identifier).to.be.equal('id');
});
});
mocha_1.describe('factoryHttp should', () => {
const stubMosaics = new index_2.Stubs.MosaicRepository('http://localhost:3000');
const stubAccounts = new index_2.Stubs.AccountRepository('http://localhost:3000');
mocha_1.it('use correct MosaicRepository', () => {
const factory = context.reader.factoryHttp;
const stubbed = sinon.stub(factory, 'createMosaicRepository').returns(stubMosaics);
const repo = factory.createMosaicRepository();
chai_1.expect(stubbed.calledOnce).to.be.true;
chai_1.expect(repo.getMosaic).to.not.be.undefined;
});
mocha_1.it('use correct AccountRepository', () => {
const factory = context.reader.factoryHttp;
const stubbed = sinon.stub(factory, 'createAccountRepository').returns(stubAccounts);
const repo = factory.createAccountRepository();
chai_1.expect(stubbed.calledOnce).to.be.true;
chai_1.expect(repo.getAccountInfo).to.not.be.undefined;
});
});
});