Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(767)

Side by Side Diff: pkg/barback/test/transformer_test.dart

Issue 198103003: Support extensions with multiple periods in Transformer.allowedExtensions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library barback.test.transformer_test; 5 library barback.test.transformer_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
11 11
12 import 'utils.dart'; 12 import 'utils.dart';
13 13
14 main() { 14 main() {
15 initConfig(); 15 initConfig();
16 16
17 group("isPrimary", () { 17 group("isPrimary", () {
18 test("defaults to allowedExtensions", () { 18 test("defaults to allowedExtensions", () {
19 var transformer = new ExtensionTransformer(".txt .bin"); 19 var transformer = new ExtensionTransformer(".txt .bin");
20 expect(transformer.isPrimary(makeAsset("foo.txt")), 20 expect(transformer.isPrimary(makeAsset("foo.txt")),
21 completion(isTrue)); 21 completion(isTrue));
22 22
23 expect(transformer.isPrimary(makeAsset("foo.bin")), 23 expect(transformer.isPrimary(makeAsset("foo.bin")),
24 completion(isTrue)); 24 completion(isTrue));
25 25
26 expect(transformer.isPrimary(makeAsset("foo.nottxt")), 26 expect(transformer.isPrimary(makeAsset("foo.nottxt")),
27 completion(isFalse)); 27 completion(isFalse));
28 }); 28 });
29 29
30 test("supports multi-level extensions with allowedExtensions", () {
31 var transformer = new ExtensionTransformer(".dart.js");
32 expect(transformer.isPrimary(makeAsset("foo.dart.js")),
33 completion(isTrue));
34
35 expect(transformer.isPrimary(makeAsset("foo.js")), completion(isFalse));
36 expect(transformer.isPrimary(makeAsset("foo.dart")), completion(isFalse));
37 });
38
39 test("throws an error for extensions without periods", () {
40 expect(() => new ExtensionTransformer("dart"), throwsFormatException);
41 });
42
30 test("allows all files if allowedExtensions is not overridden", () { 43 test("allows all files if allowedExtensions is not overridden", () {
31 var transformer = new MockTransformer(); 44 var transformer = new MockTransformer();
32 expect(transformer.isPrimary(makeAsset("foo.txt")), 45 expect(transformer.isPrimary(makeAsset("foo.txt")),
33 completion(isTrue)); 46 completion(isTrue));
34 47
35 expect(transformer.isPrimary(makeAsset("foo.bin")), 48 expect(transformer.isPrimary(makeAsset("foo.bin")),
36 completion(isTrue)); 49 completion(isTrue));
37 50
38 expect(transformer.isPrimary(makeAsset("anything")), 51 expect(transformer.isPrimary(makeAsset("anything")),
39 completion(isTrue)); 52 completion(isTrue));
(...skipping 10 matching lines...) Expand all
50 Future apply(Transform transform) => new Future.value(); 63 Future apply(Transform transform) => new Future.value();
51 } 64 }
52 65
53 class ExtensionTransformer extends Transformer { 66 class ExtensionTransformer extends Transformer {
54 final String allowedExtensions; 67 final String allowedExtensions;
55 68
56 ExtensionTransformer(this.allowedExtensions); 69 ExtensionTransformer(this.allowedExtensions);
57 70
58 Future apply(Transform transform) => new Future.value(); 71 Future apply(Transform transform) => new Future.value();
59 } 72 }
OLDNEW
« pkg/barback/lib/src/transformer.dart ('K') | « pkg/barback/lib/src/utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698