embark/test/cmd.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-03-08 13:52:06 +00:00
var Embark = require('../lib/index');
var Cmd = require('../lib/cmd');
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');
});
}
var passingLines = function () {
var lines = [];
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-22 05:13:58 +00:00
var cmd = new Cmd(Embark);
var pl = passingLines();
2017-03-08 13:56:27 +00:00
var appname = 'deleteapp';
2017-03-08 13:52:06 +00:00
cmd.newApp(appname, function (output) {
2017-03-08 13:56:27 +00:00
var 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) {
var cmd = new Cmd(Embark);
var pl = passingLines();
var appname = 'deleteapp';
cmd.newApp(undefined, function (output) {
var lines = output.split('\n');
console.log(lines);
sendLine(appname + '\n');
assert.equal(lines[0], pl[0]);
});
done();
2017-03-22 05:13:58 +00:00
});
});
2017-03-08 13:52:06 +00:00
});