Commit 2aa6ca57 by Arian Stolwijk

Add some extra CLI tests

parent a75739e2
...@@ -8,6 +8,22 @@ var path = require('path'), ...@@ -8,6 +8,22 @@ var path = require('path'),
cliPath = path.resolve(__dirname, '..', 'bin', 'node-sass'), cliPath = path.resolve(__dirname, '..', 'bin', 'node-sass'),
sampleFilename = path.resolve(__dirname, 'sample.scss'); sampleFilename = path.resolve(__dirname, 'sample.scss');
var expectedSampleCompressed = '#navbar {width:80%;height:23px;}\
#navbar ul {list-style-type:none;}\
#navbar li {float:left;}\
#navbar li a {font-weight:bold;}';
var expectedSampleNoComments = '#navbar {\n\
width: 80%;\n\
height: 23px; }\n\
\n\
#navbar ul {\n\
list-style-type: none; }\n\
\n\
#navbar li {\n\
float: left; }\n\
#navbar li a {\n\
font-weight: bold; }\n';
describe('cli', function() { describe('cli', function() {
it('should print help when run with no arguments', function(done) { it('should print help when run with no arguments', function(done) {
...@@ -57,5 +73,40 @@ describe('cli', function() { ...@@ -57,5 +73,40 @@ describe('cli', function() {
}); });
}); });
it('should compile with the --output style', function(done){
var emitter = cli(['--output-style', 'compressed', __dirname + '/sample.scss']);
emitter.on('error', function(err){
done(err);
});
emitter.on('render', function(css){
assert.equal(css, expectedSampleCompressed);
done();
});
});
it('should compile with the --source-comments option', function(done){
var emitter = cli(['--source-comments', 'none', __dirname + '/sample.scss']);
emitter.on('error', function(err){
done(err);
});
emitter.on('render', function(css){
assert.equal(css, expectedSampleNoComments);
done();
});
});
it('should write the output to the file specified with the --output option', function(done){
var resultPath = path.resolve(__dirname, '..', 'output.css');
var emitter = cli(['--output', resultPath, __dirname + '/sample.scss']);
emitter.on('error', function(err){
done(err);
});
emitter.on('render', function(css){
fs.exists(resultPath, function(exists) {
assert(exists);
fs.unlink(resultPath, done);
});
});
});
}); });
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