Commit 4fd66035 by Nathan Houle

Add sass-spec test suite

parent 0177fe8d
[submodule "libsass"]
path = libsass
url = git://github.com/hcatlin/libsass.git
[submodule "test/sass-spec"]
path = test/sass-spec
url = https://github.com/sass/sass-spec.git
Subproject commit d516aefa786f3cd3dd2914bb33d9760090176503
var assert = require('assert'),
fs = require('fs'),
path = require('path'),
sass = require('../sass');
var normalize = function(text) {
return text.replace(/\s+/g, '').replace('{', '{\n').replace(';', ';\n');
};
describe('sass-spec', function() {
var sassSpecPath = path.join(__dirname, 'sass-spec'),
sassSpecDirExists = fs.existsSync(sassSpecPath);
describe('test directory', function() {
it('it should exist', function() {
assert.ok(sassSpecDirExists);
});
});
if (sassSpecDirExists) {
var suitesPath = path.join(sassSpecPath, 'spec');
var suites = fs.readdirSync(suitesPath);
var ignoreSuites = ['todo', 'benchmarks'];
suites.forEach(function(suite) {
if (ignoreSuites.indexOf(suite) !== -1) {
return;
}
describe(suite, function() {
var suitePath = path.join(suitesPath, suite);
var tests = fs.readdirSync(suitePath);
tests.forEach(function(test) {
var testPath = path.join(suitePath, test);
it(test, function(done) {
sass.render({
file: path.join(testPath, 'input.scss'),
includePaths: [testPath, path.join(testPath, 'sub')],
success: function(css) {
var expected = fs.readFileSync(path.join(testPath, 'expected_output.css'), 'utf-8');
assert.equal(normalize(css), normalize(expected));
done();
},
error: function(error) {
done(new Error(error));
}
});
});
});
});
});
}
});
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