add tests specifically of error handling of parsing standalone mss files

master-undefined-tagcontent
Dane Springmeyer 12 years ago
parent 0c04ad07b6
commit 7d7cc2653c

@ -6,7 +6,7 @@ var carto = require('../lib/carto');
var tree = require('../lib/carto/tree');
var helper = require('./support/helper');
describe('Error handling', function() {
describe('Error handling mml+mss', function() {
helper.files('errorhandling', 'mml', function(file) {
it('should handle errors in ' + path.basename(file), function(done) {
var completed = false;
@ -45,3 +45,43 @@ helper.files('errorhandling', 'mml', function(file) {
});
});
});
describe('Error handling mss', function() {
helper.files('errorhandling', 'mss', function(file) {
it('should handle errors in ' + path.basename(file), function(done) {
var completed = false;
var renderResult;
console.log(file)
var mss = helper.mss(file);
try {
new carto.Renderer({
paths: [ path.dirname(file) ],
data_dir: path.join(__dirname, '../data'),
local_data_dir: path.join(__dirname, 'rendering'),
filename: file
}).renderMSS(mss, function (err) {
if (!err) {
console.warn("*** <--- WARNING invalid error handling test found (" + file + "): all error handling tests should throw errors!");
} else {
var result = helper.resultFile(file);
var output = err.message;
// @TODO for some reason, fs.readFile includes an additional \n
// at the end of read files. Determine why.
fs.readFile(helper.resultFile(file), 'utf8', function(err, data) {
if (!err) assert.deepEqual(output, data.substr(0, data.length - 1));
});
}
});
} catch(err) {
var result = helper.resultFile(file);
var output = err.message;
// @TODO for some reason, fs.readFile includes an additional \n
// at the end of read files. Determine why.
fs.readFile(helper.resultFile(file), 'utf8', function(err, data) {
if (!err) assert.deepEqual(output, data.substr(0, data.length - 1));
});
}
done();
});
});
});

@ -46,6 +46,10 @@ exports.mml = function(file) {
return mml;
};
exports.mss = function(file) {
return fs.readFileSync(file, 'utf-8');
};
exports.showDifferences = function(e, format) {
var changes = diff(
(format || JSON.stringify)(e.actual),

Loading…
Cancel
Save