Skip to content

Commit

Permalink
Expose CompileResult publicly, along with methods that return it
Browse files Browse the repository at this point in the history
This also exposes CompileResult.includedUrls.

Closes #1355
Partially addresses sass/embedded-protocol#62
  • Loading branch information
nex3 committed Jul 14, 2021
1 parent 43b69e6 commit 558ca0a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
5 changes: 3 additions & 2 deletions test/cli/shared/source_maps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
});

test("contains mappings", () {
var result = sass.compileStringToResult("a {b: 1 + 2}");
var result = sass.compileStringToResult("a {b: 1 + 2}", sourceMap: true);
expect(map,
containsPair("mappings", result.sourceMap!.toJson()["mappings"]));
});
Expand Down Expand Up @@ -287,7 +287,8 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
});

test("contains mappings in the generated CSS", () {
var result = sass.compileStringToResult("a {b: 1 + 2}");
var result =
sass.compileStringToResult("a {b: 1 + 2}", sourceMap: true);
expect(map,
containsPair("mappings", result.sourceMap!.toJson()["mappings"]));
});
Expand Down
30 changes: 17 additions & 13 deletions test/dart_api/importer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,28 @@ void main() {
});

test("uses an importer's source map URL", () {
var result = compileStringToResult('@import "orange";', importers: [
TestImporter((url) => Uri.parse("u:$url"), (url) {
var color = url.path;
return ImporterResult('.$color {color: $color}',
sourceMapUrl: Uri.parse("u:blue"), indented: false);
})
]);
var result = compileStringToResult('@import "orange";',
importers: [
TestImporter((url) => Uri.parse("u:$url"), (url) {
var color = url.path;
return ImporterResult('.$color {color: $color}',
sourceMapUrl: Uri.parse("u:blue"), indented: false);
})
],
sourceMap: true);

expect(result.sourceMap!.urls, contains("u:blue"));
});

test("uses a data: source map URL if the importer doesn't provide one", () {
var result = compileStringToResult('@import "orange";', importers: [
TestImporter((url) => Uri.parse("u:$url"), (url) {
var color = url.path;
return ImporterResult('.$color {color: $color}', indented: false);
})
]);
var result = compileStringToResult('@import "orange";',
importers: [
TestImporter((url) => Uri.parse("u:$url"), (url) {
var color = url.path;
return ImporterResult('.$color {color: $color}', indented: false);
})
],
sourceMap: true);

expect(
result.sourceMap!.urls,
Expand Down

0 comments on commit 558ca0a

Please sign in to comment.