dart-sass/test/dart_script_test.dart

37 lines
1.3 KiB
Dart
Raw Normal View History

// Copyright 2017 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
2017-07-07 02:36:15 +02:00
@TestOn('vm')
import 'package:package_resolver/package_resolver.dart';
import 'package:path/path.dart' as p;
2017-05-25 23:23:48 +02:00
import 'package:test/test.dart';
import 'package:test_descriptor/test_descriptor.dart' as d;
import 'package:sass/sass.dart';
import 'package:sass/src/exception.dart';
main() {
2017-05-25 23:23:48 +02:00
test("successfully imports a package URL", () async {
await d.dir("subdir", [d.file("test.scss", "a {b: 1 + 2}")]).create();
2017-05-25 23:23:48 +02:00
await d.file("test.scss", '@import "package:fake_package/test";').create();
var resolver = new SyncPackageResolver.config(
2017-05-25 23:23:48 +02:00
{"fake_package": p.toUri(p.join(d.sandbox, 'subdir'))});
2017-05-25 23:23:48 +02:00
var css = render(p.join(d.sandbox, "test.scss"), packageResolver: resolver);
expect(css, equals("a {\n b: 3;\n}"));
});
2017-05-25 23:23:48 +02:00
test("imports a package URL from a missing package", () async {
await d
.file("test.scss", '@import "package:fake_package/test_aux";')
.create();
var resolver = new SyncPackageResolver.config({});
2017-05-25 23:23:48 +02:00
expect(() => render(d.sandbox + "/test.scss", packageResolver: resolver),
throwsA(new isInstanceOf<SassRuntimeException>()));
});
}