Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1319 from xzyfer/test/import-null
Browse files Browse the repository at this point in the history
Add test coverage for existing custom importer return semantics
  • Loading branch information
xzyfer committed Dec 27, 2015
2 parents 08f1189 + 7a060a7 commit 31d54cb
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 6 deletions.
99 changes: 93 additions & 6 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ describe('api', function() {
});
}
}, function(error, result) {
assert.equal(result.css.toString().trim(), '');
assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});
});
Expand All @@ -292,7 +292,7 @@ describe('api', function() {
});
}
}, function(error, result) {
assert.equal(result.css.toString().trim(), '');
assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});
});
Expand All @@ -306,7 +306,7 @@ describe('api', function() {
};
}
}, function(error, result) {
assert.equal(result.css.toString().trim(), '');
assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});
});
Expand All @@ -320,7 +320,44 @@ describe('api', function() {
};
}
}, function(error, result) {
assert.equal(result.css.toString().trim(), '');
assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});
});


it('should fallback to default import behaviour if importer returns null for backwards compatibility', function(done) {
sass.render({
file: fixture('include-files/index.scss'),
importer: function(url, prev, done) {
done(null);
}
}, function(error, result) {
assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});
});

it('should fallback to default import behaviour if importer returns undefined for backwards compatibility', function(done) {
sass.render({
file: fixture('include-files/index.scss'),
importer: function(url, prev, done) {
done(undefined);
}
}, function(error, result) {
assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});
});

it('should fallback to default import behaviour if importer returns false for backwards compatibility', function(done) {
sass.render({
file: fixture('include-files/index.scss'),
importer: function(url, prev, done) {
done(false);
}
}, function(error, result) {
assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});
});
Expand Down Expand Up @@ -1248,7 +1285,7 @@ describe('api', function() {
}
});

assert.equal(result.css.toString().trim(), '');
assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});

Expand All @@ -1262,7 +1299,7 @@ describe('api', function() {
}
});

assert.equal(result.css.toString().trim(), '');
assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});

Expand Down Expand Up @@ -1294,6 +1331,56 @@ describe('api', function() {
done();
});



it('should fallback to default import behaviour if importer returns sass.NULL', function(done) {
var result = sass.renderSync({
file: fixture('include-files/index.scss'),
importer: function() {
return sass.NULL;
}
});

assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});

it('should fallback to default import behaviour if importer returns null for backwards compatibility', function(done) {
var result = sass.renderSync({
file: fixture('include-files/index.scss'),
importer: function() {
return null;
}
});

assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});

it('should fallback to default import behaviour if importer returns undefined for backwards compatibility', function(done) {
var result = sass.renderSync({
file: fixture('include-files/index.scss'),
importer: function() {
return undefined;
}
});

assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});

it('should fallback to default import behaviour if importer returns false for backwards compatibility', function(done) {
var result = sass.renderSync({
file: fixture('include-files/index.scss'),
importer: function() {
return false;
}
});

assert.equal(result.css.toString().trim(), '/* foo.scss */\n/* bar.scss */');
done();
});

it('should accept arrays of importers and return respect the order', function(done) {
var result = sass.renderSync({
file: fixture('include-files/index.scss'),
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/include-files/bar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* bar.scss */
1 change: 1 addition & 0 deletions test/fixtures/include-files/foo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* foo.scss */

0 comments on commit 31d54cb

Please sign in to comment.