generated from PolymeshAssociation/typescript-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Issuance.ts
59 lines (46 loc) · 1.54 KB
/
Issuance.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import BigNumber from 'bignumber.js';
import sinon from 'sinon';
import { Namespace, SecurityToken } from '~/api/entities';
import { issueTokens } from '~/api/procedures';
import { TransactionQueue } from '~/base';
import { dsMockUtils, entityMockUtils } from '~/testUtils/mocks';
import { Issuance } from '../Issuance';
describe('Issuance class', () => {
beforeAll(() => {
entityMockUtils.initMocks();
dsMockUtils.initMocks();
});
afterEach(() => {
entityMockUtils.reset();
dsMockUtils.reset();
});
afterAll(() => {
entityMockUtils.cleanup();
dsMockUtils.cleanup();
});
test('should extend namespace', () => {
expect(Issuance.prototype instanceof Namespace).toBe(true);
});
describe('method: issue', () => {
afterAll(() => {
sinon.restore();
});
test('should prepare the procedure with the correct arguments and context, and return the resulting transaction queue', async () => {
const context = dsMockUtils.getContextInstance();
const token = entityMockUtils.getSecurityTokenInstance();
const issuance = new Issuance(token, context);
const args = {
issuanceAmount: {
amount: new BigNumber(100),
},
};
const expectedQueue = ('someQueue' as unknown) as TransactionQueue<SecurityToken>;
sinon
.stub(issueTokens, 'prepare')
.withArgs({ ticker: token.ticker, ...args }, context)
.resolves(expectedQueue);
const queue = await issuance.issue(args);
expect(queue).toBe(expectedQueue);
});
});
});