Add CLI tests and setup CI #53
@ -61,6 +61,46 @@ describe('Test laconic CLI commands', () => {
|
|||||||
expect(errorOutput).toBe('');
|
expect(errorOutput).toBe('');
|
||||||
expect(result.status).toBe(0);
|
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');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user