Skip to content

Commit

Permalink
tests ~ add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rivy committed Dec 13, 2020
1 parent a2df256 commit 6a37445
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"ava": "^1.4.1",
"codecov": "^3.5.0",
"coveralls": "^3.0.5",
"cross-spawn": "^6.0.5",
"cspell": "^3.2.14",
"echo-cli": "^1.0.8",
"eslint": "^5.16.0",
Expand Down
50 changes: 50 additions & 0 deletions test/integration.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* eslint-env es6, node */
// spell-checker:ignore (modules) execa
'use strict';

const fs = require('fs');
const path = require('path');

const test = require('ava');
const spawn = require('cross-spawn');

const module_ = require('../src/lib');

// Integration tests

test('api', t => {
const paths = module_;
const api = ['home', 'temp'];

t.is(typeof paths, 'function');
t.is(Object.keys(paths).length, api.length);
api.forEach(key => {
t.is(typeof paths[key], 'function');
});
});

test('examples are executable without error (JavaScript)', t => {
const egDirPath = 'eg';
const extensions = ['.js', '.cjs', '.mjs'];

const files = fs.readdirSync(egDirPath);

files
.filter(file => {
return extensions.includes(path.extname(file));
})
.forEach(file => {
const command = 'node';
const script = path.join(egDirPath, file);
const args = [script];
const options = {shell: true, encoding: 'utf8'};

t.log({script});

const {error, status, stdout} = spawn.sync(command, args, options);

t.log({error, status, stdout});

t.deepEqual({error, status}, {error: null, status: 0});
});
});

0 comments on commit 6a37445

Please sign in to comment.