-
Notifications
You must be signed in to change notification settings - Fork 11
Make Sass implementation agnostic ( supporting dart-sass ) #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
var fs = require('fs') | ||
var path = require('path') | ||
var sass = require('node-sass') | ||
var assetFunctions = require('../') | ||
|
||
var renderAsync = function(file, options, done) { | ||
var renderAsync = function(sass, file, options, done) { | ||
options = options || {} | ||
options.images_path = __dirname + '/images' | ||
options.fonts_path = __dirname + '/fonts' | ||
options.implemantation = sass | ||
|
||
return sass.render({ | ||
functions: assetFunctions(options), | ||
file: __dirname + '/scss/' + file | ||
file: __dirname + '/scss/' + file, | ||
}, done) | ||
} | ||
|
||
var equalsFileAsync = function(file, suite, options, done) { | ||
renderAsync(file, options, function(err, result) { | ||
var equalsFileAsync = function(sass, file, suite, options, done) { | ||
renderAsync(sass, file, options, function(err, result) { | ||
expect(err).toBeNull() | ||
var cssPath = path.join(cssDir, suite, file.replace(/\.scss$/, '.css')) | ||
fs.readFile(cssPath, function(err, expected) { | ||
|
@@ -44,42 +44,46 @@ var path_asset_cache_buster = function(http_path, real_path, done) { | |
var extname = path.extname(http_path) | ||
, basename = path.basename(http_path, extname) | ||
, dirname = path.dirname(http_path) | ||
|
||
done({path: path.join(dirname, basename + '-v123') + extname, query: null}) | ||
}, 10) | ||
} | ||
|
||
var files = fs.readdirSync(sassDir) | ||
|
||
describe('basic', function() { | ||
files.forEach(function(file) { | ||
test(file, function(done) { | ||
equalsFileAsync(file, 'basic', {}, done) | ||
}) | ||
}) | ||
}) | ||
describe.each(['node-sass', 'sass'])('with require("%s")', function(impl) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently installed version of jest did not support There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for the record, the test failure was not due to the jest version ( it also failed with |
||
var sass = require(impl) | ||
|
||
describe('asset_host', function() { | ||
files.forEach(function(file) { | ||
test(file, function(done) { | ||
equalsFileAsync(file, 'asset_host', { asset_host: asset_host }, done) | ||
describe('basic', function() { | ||
files.forEach(function(file) { | ||
test(file, function(done) { | ||
equalsFileAsync(sass, file, 'basic', {}, done) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('asset_cache_buster', function() { | ||
describe('using query', function() { | ||
describe('asset_host', function() { | ||
files.forEach(function(file) { | ||
test(file, function(done) { | ||
equalsFileAsync(file, 'asset_cache_buster/query', { asset_cache_buster: query_asset_cache_buster }, done) | ||
equalsFileAsync(sass, file, 'asset_host', { asset_host: asset_host }, done) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('using path', function() { | ||
files.forEach(function(file) { | ||
test(file, function(done) { | ||
equalsFileAsync(file, 'asset_cache_buster/path', { asset_cache_buster: path_asset_cache_buster }, done) | ||
describe('asset_cache_buster', function() { | ||
describe('using query', function() { | ||
files.forEach(function(file) { | ||
test(file, function(done) { | ||
equalsFileAsync(sass, file, 'asset_cache_buster/query', { asset_cache_buster: query_asset_cache_buster }, done) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('using path', function() { | ||
files.forEach(function(file) { | ||
test(file, function(done) { | ||
equalsFileAsync(sass, file, 'asset_cache_buster/path', { asset_cache_buster: path_asset_cache_buster }, done) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.