Skip to content

Commit

Permalink
chore(tests): more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
thepiwo committed Feb 28, 2022
1 parent a79bcf3 commit 28e0859
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions tests/happy-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fs = require('fs');
const chai = require('chai');
const chaiFiles = require('chai-files');
const { isEnvRunning } = require('../src/env/env');
const { version } = require('../package.json');

chai.use(chaiFiles);
const { assert } = chai;
Expand All @@ -22,22 +23,38 @@ describe('Happy Path', () => {
fs.rmSync(cwd, { recursive: true });
});

it('init', async () => {
await exec('aeproject init', { cwd });

assert.exists(file(path.join(cwd, '.gitignore')));
assert.exists(file(path.join(cwd, 'docker-compose.yml')));
assert.exists(file(path.join(cwd, 'package.json')));
it('help', async () => {
const res = await exec('aeproject help', { cwd });
assert.equal(res.code, 0);
});

assert.exists(file(path.join(cwd, 'contracts/ExampleContract.aes')));
assert.exists(file(path.join(cwd, 'docker/accounts.json')));
assert.exists(file(path.join(cwd, 'docker/aeternity.yaml')));
assert.exists(file(path.join(cwd, 'docker/nginx.conf')));
assert.exists(file(path.join(cwd, 'test/exampleTest.js')));
it('version', async () => {
const res = await exec('aeproject --version', { cwd });
assert.equal(res.code, 0);
assert.include(res.stdout, version);
});

// eslint-disable-next-line no-restricted-syntax
for (const folder of [null, ['testprojectfolder']]) {
it(folder ? `init ${folder}` : 'init', async () => {
const res = await exec(folder ? `aeproject init ${folder}` : 'aeproject init', { cwd });
assert.equal(res.code, 0);

assert.exists(file(path.join(cwd, '.gitignore')));
assert.exists(file(path.join(cwd, 'docker-compose.yml')));
assert.exists(file(path.join(cwd, 'package.json')));

assert.exists(file(path.join(cwd, 'contracts/ExampleContract.aes')));
assert.exists(file(path.join(cwd, 'docker/accounts.json')));
assert.exists(file(path.join(cwd, 'docker/aeternity.yaml')));
assert.exists(file(path.join(cwd, 'docker/nginx.conf')));
assert.exists(file(path.join(cwd, 'test/exampleTest.js')));
});
}

it('env', async () => {
await exec('aeproject env', { cwd });
const res = await exec('aeproject env', { cwd });
assert.equal(res.code, 0);
assert.isTrue(await isEnvRunning(cwd));
});

Expand All @@ -49,7 +66,8 @@ describe('Happy Path', () => {
});

it('env --stop', async () => {
await exec('aeproject env --stop', { cwd });
const res = await exec('aeproject env --stop', { cwd });
assert.equal(res.code, 0);
assert.isFalse(await isEnvRunning(cwd));
});
});

0 comments on commit 28e0859

Please sign in to comment.