diff --git a/test/cli.test.ts b/test/cli.test.ts index aa96e70..6ed0af6 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -61,6 +61,46 @@ describe('Test laconic CLI commands', () => { expect(errorOutput).toBe(''); expect(result.status).toBe(0); }); + + describe('laconic cns bond ', () => { + 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(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'); + }); + }); }); }); });