From abe91956154c5de1795d334203b2ae985cad04ea Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 24 Jan 2024 14:32:12 +0530 Subject: [PATCH] Add tests for bond create and list commands --- test/cli.test.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) 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'); + }); + }); }); }); });