Skip to content

Commit

Permalink
✅ Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Jun 18, 2024
1 parent e708ebf commit 757b9ec
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/core/test/assets_gen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ void main() {
await expectedAssetsGen(pubspec, generated, fact);
});

test('Assets with duplicate flavoring entries', () async {
const pubspec =
'test_resources/pubspec_assets_flavored_duplicate_entry.yaml';
const fact =
'test_resources/actual_data/assets_flavored_duplicate_entry.gen.dart';
const generated =
'test_resources/lib/gen/assets_flavored_duplicate_entry.gen.dart';

await expectLater(
() => runAssetsGen(pubspec, generated, fact),
throwsA(isA<StateError>()),
);
});

test('Assets with terrible names (camelCase)', () async {
// See [AssetTypeIterable.mapToUniqueAssetType] for the rules for picking
// identifer names.
Expand Down
7 changes: 7 additions & 0 deletions packages/core/test/config_test.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:flutter_gen_core/settings/flavored_asset.dart';
import 'package:test/test.dart';

Expand All @@ -24,6 +25,12 @@ void main() {
FlavoredAsset(path: '1').copyWith(path: '2'),
predicate<FlavoredAsset>((e) => e.path == '2'),
);
expect(
FlavoredAsset(path: '1').copyWith(flavors: {'test'}),
predicate<FlavoredAsset>(
(e) => SetEquality().equals(e.flavors, {'test'}),
),
);
});
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: test

flutter_gen:
output: lib/gen/ # Optional (default: lib/gen/)
line_length: 80 # Optional (default: 80)

integrations:
flutter_svg: true
flare_flutter: true

flutter:
assets:
- assets/images
- assets/images/chip3/chip3.jpg
- assets/images/chip3/chip3.jpg # duplicated
- assets/images/icons/fuchsia.svg
- assets/images/icons/kmm.svg
- assets/images/icons/paint.svg
- assets/images/icons/[email protected]
- assets/json/
- pictures/chip5.jpg
- assets/flare/
- assets/movie/
- assets/unknown/unknown_mime_type.bk
- CHANGELOG.md
- path: assets/images/chip4/
flavors:
- test
- path: assets/images/chip4/
flavors:
- another_test

0 comments on commit 757b9ec

Please sign in to comment.