Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/cliAccessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ describe('Test command line interface functionality', function () {

describe('CLI accessibility', function () {
it('`create-elm-app` command should be available', function () {
var output = spawn.sync('create-elm-app').output;
const output = spawn.sync('create-elm-app').output;
expect(output.toString()).to.have.string('Usage: create-elm-app <project-directory>');
});

it('`elm-app` command should be available', function () {
var result = spawn.sync('elm-app');
var output = result.output;
const result = spawn.sync('elm-app');
const output = result.output;
expect(output.toString()).to.have.string('Usage: elm-app <command>');
});

it('`elm-app package` command should be available', function () {
var result = spawn.sync('elm-app', [ 'package' ]);
var output = concatsStringBuffers(result.output);
const result = spawn.sync('elm-app', [ 'package' ]);
const output = concatsStringBuffers(result.output);
expect(output).to.have.string('install and publish elm packages');
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/elm-app.build.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('Building Elm application with `elm-app build`', function () {
});

it('`elm-app build` should succeed in `' + testAppName + '`', function () {
var result = spawn.sync('node', [ elmAppCmd, 'build' ]);
var outputString = result.output.map(function (out) {
const result = spawn.sync('node', [ elmAppCmd, 'build' ]);
const outputString = result.output.map(function (out) {
return (out !== null) ? out.toString() : '';
}).join('');
expect(result.status).to.be.equal(0, 'Incorrect exit status code');
Expand Down
42 changes: 42 additions & 0 deletions tests/elm-app.test.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const path = require('path');
const spawn = require('cross-spawn');
const rimraf = require('rimraf');
const expect = require('chai').expect;


const testAppName = 'test-app';
const rootDir = path.resolve(__dirname, '..');
const testAppDir = path.join(rootDir, testAppName);
const createElmAppCmd = path.join(rootDir, 'bin/create-elm-app-cli.js');
const elmAppCmd = path.join(rootDir, 'bin/elm-app-cli.js');

describe('Testing Elm application with `elm-app test` (Please wait...)', function () {
before(function (done) {
const cmd = spawn.sync('node', [ createElmAppCmd, testAppName ]);

if (cmd.status === 0) {
process.chdir(testAppDir);
done();
} else {
done(false);
}
});

after(function () {
process.chdir(rootDir);
rimraf.sync(testAppDir);
});

it('`elm-app test` should succeed in `' + testAppName + '`', function () {
const result = spawn.sync('node', [ elmAppCmd, 'test' ]);
const outputString = result.output.map(function (out) {
return (out !== null) ? out.toString() : '';
}).join('');

expect(result.status).to.be.at.least(1);
expect(outputString).to.have.string('This test should fail');
expect(outputString).to.have.string('failed as expected!');
}).timeout(2 * 60 * 1000);
});