| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import 'package:path/path.dart' as p; | 7 import 'package:path/path.dart' as p; |
| 8 import 'package:test/test.dart'; | 8 import 'package:test/test.dart'; |
| 9 | 9 |
| 10 import 'package:package_resolver/package_resolver.dart'; | 10 import 'package:package_resolver/package_resolver.dart'; |
| 11 | 11 |
| 12 void main() { | 12 void main() { |
| 13 var resolver; | 13 var resolver; |
| 14 setUp(() { | 14 setUp(() { |
| 15 resolver = new SyncPackageResolver.root("file:///foo/bar"); | 15 resolver = new SyncPackageResolver.root("file:///foo/bar"); |
| 16 }); | 16 }); |
| 17 | 17 |
| 18 group("constructor", () { | 18 group("constructor", () { |
| 19 test("with a URI object", () { | 19 test("with a URI object", () { |
| 20 var resolver = | 20 var resolver = |
| 21 new SyncPackageResolver.root(Uri.parse("file:///foo/bar/")); | 21 new SyncPackageResolver.root(Uri.parse("file:///foo/bar/")); |
| 22 expect(resolver.packageRoot, equals(Uri.parse("file:///foo/bar/"))); | 22 expect(resolver.packageRoot, equals(Uri.parse("file:///foo/bar/"))); |
| 23 }); | 23 }); |
| 24 | 24 |
| 25 test("with a URI without a path component", () { |
| 26 var resolver = |
| 27 new SyncPackageResolver.root(Uri.parse("http://localhost:1234")); |
| 28 expect(resolver.packageRoot, equals(Uri.parse("http://localhost:1234/"))); |
| 29 }); |
| 30 |
| 25 test("with an invalid URI type", () { | 31 test("with an invalid URI type", () { |
| 26 expect(() => new SyncPackageResolver.root(12), throwsArgumentError); | 32 expect(() => new SyncPackageResolver.root(12), throwsArgumentError); |
| 27 }); | 33 }); |
| 28 }); | 34 }); |
| 29 | 35 |
| 30 test("exposes a null config map", () { | 36 test("exposes a null config map", () { |
| 31 expect(resolver.packageConfigMap, isNull); | 37 expect(resolver.packageConfigMap, isNull); |
| 32 }); | 38 }); |
| 33 | 39 |
| 34 test("exposes a null config URI", () { | 40 test("exposes a null config URI", () { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 expect(resolver.packagePath("foo"), equals(p.join(sandbox, "foo"))); | 144 expect(resolver.packagePath("foo"), equals(p.join(sandbox, "foo"))); |
| 139 expect(resolver.packagePath("bar"), isNull); | 145 expect(resolver.packagePath("bar"), isNull); |
| 140 }); | 146 }); |
| 141 | 147 |
| 142 test("without a file: scheme", () { | 148 test("without a file: scheme", () { |
| 143 var resolver = new SyncPackageResolver.root("http://dartlang.org/bar"); | 149 var resolver = new SyncPackageResolver.root("http://dartlang.org/bar"); |
| 144 expect(resolver.packagePath("foo"), isNull); | 150 expect(resolver.packagePath("foo"), isNull); |
| 145 }); | 151 }); |
| 146 }); | 152 }); |
| 147 } | 153 } |
| OLD | NEW |