embark-area-51/test/cmd.js

53 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2017-03-29 17:57:22 +00:00
let Embark = require('../lib/index');
2018-08-09 12:30:58 +00:00
let Cmd = require('../cmd/cmd');
2017-03-08 13:52:06 +00:00
2017-03-22 05:13:58 +00:00
// Function to send a line to stdin
function sendLine(line) {
setImmediate(function () {
process.stdin.emit('data', line + '\n');
});
}
2017-03-29 17:57:22 +00:00
let passingLines = function () {
let lines = [];
2017-03-22 05:13:58 +00:00
lines.push('Initializing Embark Template....');
lines.push('Installing packages.. this can take a few seconds');
lines.push('Init complete');
return lines;
};
2017-03-08 13:52:06 +00:00
describe('embark.Cmd', function () {
2017-03-12 03:23:30 +00:00
this.timeout(0);
2017-03-08 13:52:06 +00:00
2017-03-22 05:13:58 +00:00
describe('#new', function () {
2017-03-08 13:52:06 +00:00
it('it should create an app with a name', function (done) {
2017-03-29 17:57:22 +00:00
let cmd = new Cmd(Embark);
let pl = passingLines();
let appname = 'deleteapp';
2017-03-08 13:52:06 +00:00
cmd.newApp(appname, function (output) {
2017-03-29 17:57:22 +00:00
let lines = output.split('\n');
2017-03-22 05:13:58 +00:00
console.log(lines);
assert.equal(lines[0], pl[0]);
assert.equal(lines[1], pl[1]);
assert.equal(lines[2], pl[2]);
2017-03-08 13:52:06 +00:00
assert.equal(lines[3], 'App ready at ./' + appname);
2017-03-22 05:13:58 +00:00
});
done();
2017-03-08 13:52:06 +00:00
});
2017-03-12 03:23:30 +00:00
2017-03-22 05:13:58 +00:00
it('it should prompt when given an empty app name', function (done) {
2017-03-29 17:57:22 +00:00
let cmd = new Cmd(Embark);
let pl = passingLines();
let appname = 'deleteapp';
2017-03-22 05:13:58 +00:00
cmd.newApp(undefined, function (output) {
2017-03-29 17:57:22 +00:00
let lines = output.split('\n');
2017-03-22 05:13:58 +00:00
console.log(lines);
sendLine(appname + '\n');
assert.equal(lines[0], pl[0]);
});
done();
2017-03-22 05:13:58 +00:00
});
});
2018-08-08 19:05:22 +00:00
});