| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library barback.test.transformer_test; |
| 6 |
| 7 import 'dart:async'; |
| 8 |
| 9 import 'package:barback/barback.dart'; |
| 10 import 'package:unittest/unittest.dart'; |
| 11 |
| 12 import 'utils.dart'; |
| 13 |
| 14 main() { |
| 15 initConfig(); |
| 16 |
| 17 group("isPrimary", () { |
| 18 test("defaults to allowedExtensions", () { |
| 19 var transformer = new ExtensionTransformer(".txt .bin"); |
| 20 expect(transformer.isPrimary(makeAsset("foo.txt")), |
| 21 completion(isTrue)); |
| 22 |
| 23 expect(transformer.isPrimary(makeAsset("foo.bin")), |
| 24 completion(isTrue)); |
| 25 |
| 26 expect(transformer.isPrimary(makeAsset("foo.nottxt")), |
| 27 completion(isFalse)); |
| 28 }); |
| 29 |
| 30 test("allows all files if allowedExtensions is not overridden", () { |
| 31 var transformer = new MockTransformer(); |
| 32 expect(transformer.isPrimary(makeAsset("foo.txt")), |
| 33 completion(isTrue)); |
| 34 |
| 35 expect(transformer.isPrimary(makeAsset("foo.bin")), |
| 36 completion(isTrue)); |
| 37 |
| 38 expect(transformer.isPrimary(makeAsset("anything")), |
| 39 completion(isTrue)); |
| 40 }); |
| 41 }); |
| 42 } |
| 43 |
| 44 Asset makeAsset(String path) => |
| 45 new Asset.fromString(new AssetId.parse("app|$path"), ""); |
| 46 |
| 47 class MockTransformer extends Transformer { |
| 48 MockTransformer(); |
| 49 |
| 50 Future apply(Transform transform) => new Future.value(); |
| 51 } |
| 52 |
| 53 class ExtensionTransformer extends Transformer { |
| 54 final String allowedExtensions; |
| 55 |
| 56 ExtensionTransformer(this.allowedExtensions); |
| 57 |
| 58 Future apply(Transform transform) => new Future.value(); |
| 59 } |
| OLD | NEW |