OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.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 library pub_tests; | 5 library pub_tests; |
6 | 6 |
7 import 'package:scheduled_test/scheduled_test.dart'; | 7 import 'package:scheduled_test/scheduled_test.dart'; |
8 import '../../descriptor.dart' as d; | 8 import '../../descriptor.dart' as d; |
9 import '../../test_pub.dart'; | 9 import '../../test_pub.dart'; |
10 import '../utils.dart'; | 10 import '../utils.dart'; |
11 | 11 |
12 main() { | 12 main() { |
13 // TODO(rnystrom): Split into independent tests. | 13 // TODO(rnystrom): Split into independent tests. |
14 initConfig(); | 14 initConfig(); |
15 setUp(() { | 15 setUp(() { |
16 d.dir("foo", [ | 16 d.dir( |
17 d.libPubspec("foo", "0.0.1"), | 17 "foo", |
18 d.dir("lib", [ | 18 [ |
19 d.file("foo.dart", "foo") | 19 d.libPubspec("foo", "0.0.1"), |
20 ]) | 20 d.dir("lib", [d.file("foo.dart", "foo")])]).create(); |
21 ]).create(); | |
22 | 21 |
23 d.dir(appPath, [ | 22 d.dir(appPath, [d.appPubspec({ |
24 d.appPubspec({ | 23 "foo": { |
25 "foo": {"path": "../foo"} | 24 "path": "../foo" |
| 25 } |
26 }), | 26 }), |
27 d.dir("lib", [ | 27 d.dir("lib", [d.file("myapp.dart", "myapp"),]), |
28 d.file("myapp.dart", "myapp"), | 28 d.dir( |
29 ]), | 29 "test", |
30 d.dir("test", [ | 30 [d.file("index.html", "<body>"), d.dir("sub", [d.file("bar.html",
"bar"),])]), |
31 d.file("index.html", "<body>"), | 31 d.dir( |
32 d.dir("sub", [ | 32 "web", |
33 d.file("bar.html", "bar"), | 33 [ |
34 ]) | 34 d.file("index.html", "<body>"), |
35 ]), | 35 d.dir("sub", [d.file("bar.html", "bar"),])])]).create(); |
36 d.dir("web", [ | |
37 d.file("index.html", "<body>"), | |
38 d.dir("sub", [ | |
39 d.file("bar.html", "bar"), | |
40 ]) | |
41 ]) | |
42 ]).create(); | |
43 }); | 36 }); |
44 | 37 |
45 integration("converts URLs to matching asset ids in web/", () { | 38 integration("converts URLs to matching asset ids in web/", () { |
46 pubServe(shouldGetFirst: true); | 39 pubServe(shouldGetFirst: true); |
47 expectWebSocketResult("urlToAssetId", { | 40 expectWebSocketResult("urlToAssetId", { |
48 "url": getServerUrl("web", "index.html") | 41 "url": getServerUrl("web", "index.html") |
49 }, {"package": "myapp", "path": "web/index.html"}); | 42 }, { |
| 43 "package": "myapp", |
| 44 "path": "web/index.html" |
| 45 }); |
50 endPubServe(); | 46 endPubServe(); |
51 }); | 47 }); |
52 | 48 |
53 integration("converts URLs to matching asset ids in subdirectories of web/", | 49 integration( |
| 50 "converts URLs to matching asset ids in subdirectories of web/", |
54 () { | 51 () { |
55 pubServe(shouldGetFirst: true); | 52 pubServe(shouldGetFirst: true); |
56 expectWebSocketResult("urlToAssetId", { | 53 expectWebSocketResult("urlToAssetId", { |
57 "url": getServerUrl("web", "sub/bar.html") | 54 "url": getServerUrl("web", "sub/bar.html") |
58 }, {"package": "myapp", "path": "web/sub/bar.html"}); | 55 }, { |
| 56 "package": "myapp", |
| 57 "path": "web/sub/bar.html" |
| 58 }); |
59 endPubServe(); | 59 endPubServe(); |
60 }); | 60 }); |
61 | 61 |
62 integration("converts URLs to matching asset ids in test/", () { | 62 integration("converts URLs to matching asset ids in test/", () { |
63 pubServe(shouldGetFirst: true); | 63 pubServe(shouldGetFirst: true); |
64 expectWebSocketResult("urlToAssetId", { | 64 expectWebSocketResult("urlToAssetId", { |
65 "url": getServerUrl("test", "index.html") | 65 "url": getServerUrl("test", "index.html") |
66 }, {"package": "myapp", "path": "test/index.html"}); | 66 }, { |
| 67 "package": "myapp", |
| 68 "path": "test/index.html" |
| 69 }); |
67 endPubServe(); | 70 endPubServe(); |
68 }); | 71 }); |
69 | 72 |
70 integration("converts URLs to matching asset ids in subdirectories of test/", | 73 integration( |
| 74 "converts URLs to matching asset ids in subdirectories of test/", |
71 () { | 75 () { |
72 pubServe(shouldGetFirst: true); | 76 pubServe(shouldGetFirst: true); |
73 expectWebSocketResult("urlToAssetId", { | 77 expectWebSocketResult("urlToAssetId", { |
74 "url": getServerUrl("test", "sub/bar.html") | 78 "url": getServerUrl("test", "sub/bar.html") |
75 }, {"package": "myapp", "path": "test/sub/bar.html"}); | 79 }, { |
| 80 "package": "myapp", |
| 81 "path": "test/sub/bar.html" |
| 82 }); |
76 endPubServe(); | 83 endPubServe(); |
77 }); | 84 }); |
78 | 85 |
79 integration("converts URLs to matching asset ids in the entrypoint's lib/", | 86 integration( |
| 87 "converts URLs to matching asset ids in the entrypoint's lib/", |
80 () { | 88 () { |
81 // Path in root package's lib/. | 89 // Path in root package's lib/. |
82 pubServe(shouldGetFirst: true); | 90 pubServe(shouldGetFirst: true); |
83 expectWebSocketResult("urlToAssetId", { | 91 expectWebSocketResult("urlToAssetId", { |
84 "url": getServerUrl("web", "packages/myapp/myapp.dart") | 92 "url": getServerUrl("web", "packages/myapp/myapp.dart") |
85 }, {"package": "myapp", "path": "lib/myapp.dart"}); | 93 }, { |
| 94 "package": "myapp", |
| 95 "path": "lib/myapp.dart" |
| 96 }); |
86 endPubServe(); | 97 endPubServe(); |
87 }); | 98 }); |
88 | 99 |
89 integration("converts URLs to matching asset ids in a dependency's lib/", () { | 100 integration("converts URLs to matching asset ids in a dependency's lib/", () { |
90 // Path in lib/. | 101 // Path in lib/. |
91 pubServe(shouldGetFirst: true); | 102 pubServe(shouldGetFirst: true); |
92 expectWebSocketResult("urlToAssetId", { | 103 expectWebSocketResult("urlToAssetId", { |
93 "url": getServerUrl("web", "packages/foo/foo.dart") | 104 "url": getServerUrl("web", "packages/foo/foo.dart") |
94 }, {"package": "foo", "path": "lib/foo.dart"}); | 105 }, { |
| 106 "package": "foo", |
| 107 "path": "lib/foo.dart" |
| 108 }); |
95 endPubServe(); | 109 endPubServe(); |
96 }); | 110 }); |
97 } | 111 } |
OLD | NEW |