Add tests for bond create and list commands

This commit is contained in:
Prathamesh Musale 2024-01-24 14:32:12 +05:30
parent 055f903ce2
commit abe9195615

View File

@ -61,6 +61,46 @@ describe('Test laconic CLI commands', () => {
expect(errorOutput).toBe('');
expect(result.status).toBe(0);
});
describe('laconic cns bond <command>', () => {
let createdBondId: string;
test('laconic cns bond create', async () => {
const result = spawnSync('laconic', ['cns', 'bond', 'create', '--type', 'aphoton', '--quantity', '1000000000', '--gas', '200000', '--fees', '200000aphoton']);
const output = result.stdout.toString().trim();
const errorOutput = result.stderr.toString().trim();
expect(errorOutput).toBe('');
expect(result.status).toBe(0);
expect(output.length).toBeGreaterThan(0);
const outputObj = JSON.parse(output);
// Expect output object to resultant bond id
expect(outputObj).toHaveProperty('bondId');
createdBondId = outputObj.bondId;
});
test('laconic cns bond list', async () => {
const result = spawnSync('laconic', ['cns', 'bond', 'list']);
const output = result.stdout.toString().trim();
const errorOutput = result.stderr.toString().trim();
expect(errorOutput).toBe('');
expect(result.status).toBe(0);
expect(output.length).toBeGreaterThan(0);
const outputObj = Array.from<any>(JSON.parse(output));
// Expect output object to an array of bonds
expect(outputObj.length).toEqual(1);
expect(outputObj[0]).toHaveProperty('id', createdBondId);
expect(outputObj[0]).toHaveProperty('owner');
expect(outputObj[0]).toHaveProperty('balance');
});
});
});
});
});