Skip to content

Commit

Permalink
test: improved exec env, assert file existence
Browse files Browse the repository at this point in the history
  • Loading branch information
thepiwo committed Feb 28, 2022
1 parent 0992920 commit a9a96e1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "eslint .",
"lint:fix": "eslint --ext .js --fix .",
"lint:ci": "eslint --ext .js --max-warnings=0 .",
"test": "npm link && mocha ./tests/**/*.js --timeout 0 --exit"
"test": "mocha ./tests/**/*.js --timeout 0 --exit"
},
"license": "ISC",
"dependencies": {
Expand All @@ -22,6 +22,7 @@
},
"devDependencies": {
"chai": "^4.3.6",
"chai-files": "^1.4.0",
"eslint": "^8.9.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.4",
Expand Down
20 changes: 19 additions & 1 deletion tests/happy-path.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
const path = require('path');
const { exec } = require('promisify-child-process');
const { exec: execP } = require('promisify-child-process');
const fs = require('fs');
const chai = require('chai');
const chaiFiles = require('chai-files');

chai.use(chaiFiles);
const { assert } = chai;
const { file } = chaiFiles;

const cwd = path.join(process.cwd(), '.testdir');
const exec = (cmd, options) => execP(`source ~/.profile;${cmd}`, options);

describe('Happy Path', () => {
before(async () => {
await exec('npm link');
if (!fs.existsSync(cwd)) fs.mkdirSync(cwd);
});

Expand All @@ -15,6 +23,16 @@ describe('Happy Path', () => {

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')));

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 () => {
Expand Down

0 comments on commit a9a96e1

Please sign in to comment.