-
-
Notifications
You must be signed in to change notification settings - Fork 142
/
colors_gen_test.dart
66 lines (54 loc) · 2.37 KB
/
colors_gen_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
@TestOn('vm')
import 'dart:io';
import 'package:dart_style/dart_style.dart';
import 'package:flutter_gen_core/generators/colors_generator.dart';
import 'package:flutter_gen_core/settings/color_path.dart';
import 'package:flutter_gen_core/settings/config.dart';
import 'package:flutter_gen_core/utils/error.dart';
import 'package:test/test.dart';
import 'gen_test_helper.dart';
void main() {
group('Test Color generator', () {
test('Colors on pubspec.yaml', () async {
const pubspec = 'test_resources/pubspec_colors.yaml';
const fact = 'test_resources/actual_data/colors.gen.dart';
const generated = 'test_resources/lib/gen/colors.gen.dart';
await expectedColorsGen(pubspec, generated, fact);
});
test('Wrong colors settings on pubspec.yaml', () async {
final pubspec = File('test_resources/pubspec_colors_no_inputs.yaml');
final config = loadPubspecConfig(pubspec);
final formatter = DartFormatter(
pageWidth: config.pubspec.flutterGen.lineLength, lineEnding: '\n');
expect(() {
return generateColors(
pubspec, formatter, config.pubspec.flutterGen.colors);
}, throwsA(isA<InvalidSettingsException>()));
});
test('Wrong colors settings on pubspec.yaml', () async {
final pubspec = File('test_resources/pubspec_colors_no_inputs_list.yaml');
final config = loadPubspecConfig(pubspec);
final formatter = DartFormatter(
pageWidth: config.pubspec.flutterGen.lineLength, lineEnding: '\n');
expect(() {
return generateColors(
pubspec, formatter, config.pubspec.flutterGen.colors);
}, throwsA(isA<InvalidSettingsException>()));
});
test('ColorPath Tests', () async {
const colorPath = ColorPath('test_resources/assets/color/colors.xml');
expect(colorPath.mime, 'application/xml');
expect(colorPath.isXml, isTrue);
const wrongColorPath = ColorPath('test_resources/assets/json/map.json');
expect(wrongColorPath.isXml, isFalse);
});
test('Change the class name', () async {
const pubspec = 'test_resources/pubspec_colors_change_class_name.yaml';
const fact =
'test_resources/actual_data/colors_change_class_name.gen.dart';
const generated =
'test_resources/lib/gen/colors_change_class_name.gen.dart';
await expectedColorsGen(pubspec, generated, fact);
});
});
}