Commit be5d9380 by Takashi Mizohata Committed by xzyfer

Add test case for importer callback order

Closes #998
parent 71f9428d
......@@ -258,6 +258,26 @@ describe('api', function() {
});
});
it('should should resolve imports depth first', function (done) {
var actualImportOrder = [];
var expectedImportOrder = [
'a', '_common', 'vars', 'struct', 'a1', 'common', 'vars', 'struct', 'b', 'b1'
];
var expected = read(fixture('depth-first/expected.css'));
sass.render({
file: fixture('depth-first/index.scss'),
importer: function (url, prev, done) {
actualImportOrder.push(url);
done();
}
}, function(error, result) {
assert.equal(result.css.toString().trim(), expected);
assert.deepEqual(actualImportOrder, expectedImportOrder);
done();
});
});
it('should override imports with "file" as input and fires callback with file and contents', function(done) {
sass.render({
file: fixture('include-files/index.scss'),
......
@import "vars";
@import "struct";
.myvars {
content: quote($import_counter);
}
.common-struct {
content: "common-struct";
}
$import_counter: $import_counter + 1;
.common-vars {
content: "common-vars";
}
@import "_common";
@import "a1";
.a2 {
content: "a2";
}
@import "b1";
.b2 {
content: "b2";
}
.common-vars {
content: "common-vars"; }
.common-struct {
content: "common-struct"; }
.myvars {
content: "1"; }
.a1 {
content: "a1"; }
.a2 {
content: "a2"; }
.common-vars {
content: "common-vars"; }
.common-struct {
content: "common-struct"; }
.myvars {
content: "2"; }
.b1 {
content: "b1"; }
.b2 {
content: "b2"; }
#the-last {
content: "LAST"; }
\ No newline at end of file
$import_counter: 0;
@import "a";
@import "common";
@import "b";
#the-last {
content: "LAST";
}
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