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); + }); + }); }); }); });