Commit 98e26a9e by Alan Plum

Added tests for #451.

If isTTY is falsey (i.e. empty), the cli will attempt to read from stdin even if it is passed an input filename.
parent f04930c4
......@@ -102,6 +102,24 @@ describe('cli', function() {
});
});
it('should compile sample.scss as sample.css without isTTY', function(done) {
this.timeout(6000);
var env = assign(process.env, { isTTY: '' });
var resultPath = path.join(__dirname, 'sample.css');
exec('node ' + cliPath + ' ' + sampleFilename, {
cwd: __dirname,
env: env
}, function(err) {
assert.equal(err, null);
fs.exists(resultPath, function(exists) {
assert(exists);
fs.unlink(resultPath, done);
});
});
});
it('should compile sample.scss to ../out.css', function(done) {
this.timeout(6000);
var env = assign(process.env, { isTTY: true });
......@@ -193,6 +211,43 @@ describe('cli', function() {
});
});
it('should write to stdout with the --stdout option without isTTY', function(done) {
this.timeout(6000);
var env = assign(process.env, { isTTY: '' });
exec('node ' + cliPath + ' --stdout ' + sampleScssPath, {
cwd: __dirname,
env: env
}, function(err, stdout) {
if (err) {
done(err);
} else {
assert.equal(stdout.replace(/[\n\r]$/, ''), expectedSampleNoComments);
done();
}
});
});
it('should not write to disk with the --stdout option without isTTY', function(done) {
this.timeout(6000);
var env = assign(process.env, { isTTY: '' });
exec('node ' + cliPath + ' --stdout ' + sampleScssPath, {
cwd: __dirname,
env: env
}, function(err) {
if (err) {
done(err);
} else {
fs.exists(sampleCssOutputPath, function(exists) {
if (exists) {fs.unlinkSync(sampleCssOutputPath);}
assert(!exists);
done();
});
}
});
});
it('should not exit with the --watch option', function(done) {
var command = cliPath + ' --watch ' + sampleScssPath;
var env = assign(process.env, { isTTY: true });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment