From 75493f05e386ece741121c800e8b12aa049aba11 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 24 Jan 2024 19:10:49 +0530 Subject: [PATCH] Add test for command to fetch account details --- test/cli.test.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/cli.test.ts b/test/cli.test.ts index 2541fce..dda9afa 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -31,6 +31,7 @@ describe('Test laconic CLI commands', () => { }); describe('laconic cns ', () => { + const initialAccountBalance = Number('100000000000000000000000000'); const existingAccount = process.env.EXISTING_ACCOUNT; assert(existingAccount, 'EXISTING_ACCOUNT not set in env'); @@ -137,6 +138,38 @@ describe('Test laconic CLI commands', () => { expect(outputObj[0]).toEqual(expectedBond); }); }); + + describe('laconic cns account ', () => { + test('laconic cns account get --address ', async () => { + const result = spawnSync('laconic', ['cns', 'account', 'get', '--address', existingAccount]); + + 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)); + + // Expected account + const expectedAccount = { + address: existingAccount, + number: 0, + sequence: 2, + balance: [ + { + type: "aphoton" + } + ] + }; + + expect(outputObj.length).toEqual(1); + expect(outputObj[0]).toMatchObject(expectedAccount); + expect(Number(outputObj[0].balance[0].quantity)).toBeGreaterThan(0); + expect(Number(outputObj[0].balance[0].quantity)).toBeLessThan(initialAccountBalance); + }); + }); }); }); });