Skip to content

Commit

Permalink
test: use matchers instead of actual values
Browse files Browse the repository at this point in the history
  • Loading branch information
p-mazhnik committed Aug 3, 2022
1 parent 284d0b5 commit e2a077a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions test/android_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void main() {
expect(
FlutterLauncherIconsConfig.fromJson(flutterIconsConfig)
.isCustomAndroidFile,
false,
isFalse,
);

final Map<String, dynamic> flutterIconsNewIconConfig = <String, dynamic>{
Expand All @@ -46,7 +46,7 @@ void main() {
expect(
FlutterLauncherIconsConfig.fromJson(flutterIconsNewIconConfig)
.isCustomAndroidFile,
true,
isTrue,
);
});

Expand All @@ -60,7 +60,7 @@ void main() {
expect(
FlutterLauncherIconsConfig.fromJson(flutterIconsNewIconConfig)
.getImagePathAndroid(),
'assets/images/icon-android.png',
equals('assets/images/icon-android.png'),
);
});

Expand Down
6 changes: 3 additions & 3 deletions test/flutter_launcher_icons_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,18 @@ void main() {
final configs = FlutterLauncherIconsConfig.loadConfigFromPath(path, '.');
expect(configs, isNotNull);
const String imagePath = 'assets/images/icon-710x599.png';
expect(configs!.imagePath, imagePath);
expect(configs!.imagePath, equals(imagePath));
// android configs
expect(configs.android, isTrue);
expect(configs.imagePathAndroid, isNull);
expect(configs.getImagePathAndroid(), imagePath);
expect(configs.getImagePathAndroid(), equals(imagePath));
expect(configs.adaptiveIconBackground, isNull);
expect(configs.adaptiveIconForeground, isNull);
expect(configs.minSdkAndroid, equals(21));
// ios configs
expect(configs.ios, isTrue);
expect(configs.imagePathIOS, isNull);
expect(configs.getImagePathIOS(), imagePath);
expect(configs.getImagePathIOS(), equals(imagePath));
expect(configs.removeAlphaIOS, isFalse);
// web configs
expect(configs.webConfig, isNull);
Expand Down
30 changes: 15 additions & 15 deletions test/main_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:flutter_launcher_icons/flutter_launcher_icons_config.dart';
import 'package:flutter_launcher_icons/ios.dart' as ios;
import 'package:flutter_launcher_icons/main.dart' show defaultConfigFile;
import 'package:flutter_launcher_icons/main.dart' as main_dart;
import 'package:path/path.dart';
import 'package:path/path.dart' show join;
import 'package:test/test.dart';

// Unit tests for main.dart
Expand Down Expand Up @@ -61,7 +61,7 @@ flutter_icons:
final FlutterLauncherIconsConfig? config =
main_dart.loadConfigFileFromArgResults(argResults);
expect(config, isNotNull);
expect(config!.android, true);
expect(config!.android, isTrue);
});
test('default_use_pubspec', () async {
await setCurrentDirectory('pubspec_only');
Expand All @@ -74,7 +74,7 @@ flutter_icons:
final FlutterLauncherIconsConfig? config =
main_dart.loadConfigFileFromArgResults(argResults);
expect(config, isNotNull);
expect(config!.ios, false);
expect(config!.ios, isFalse);

// read pubspec if provided file is not found
argResults = parser.parse(<String>['-f', defaultConfigFile]);
Expand All @@ -93,7 +93,7 @@ flutter_icons:
final FlutterLauncherIconsConfig? config =
main_dart.loadConfigFileFromArgResults(argResults);
expect(config, isNotNull);
expect(config!.ios, true);
expect(config!.ios, isTrue);

// should fail if no argument
argResults = parser.parse(<String>[]);
Expand All @@ -112,15 +112,15 @@ flutter_icons:
'ios': true
};
final config = FlutterLauncherIconsConfig.fromJson(flutterIconsConfig);
expect(config.getImagePathAndroid(), 'assets/images/icon-710x599.png');
expect(config.getImagePathIOS(), 'assets/images/icon-710x599.png');
expect(config.getImagePathAndroid(), equals('assets/images/icon-710x599.png'));
expect(config.getImagePathIOS(), equals('assets/images/icon-710x599.png'));
final Map<String, dynamic> flutterIconsConfigAndroid = <String, dynamic>{
'image_path_android': 'assets/images/icon-710x599.png',
'android': true,
'ios': true
};
final configAndroid = FlutterLauncherIconsConfig.fromJson(flutterIconsConfigAndroid);
expect(configAndroid.getImagePathAndroid(), 'assets/images/icon-710x599.png');
expect(configAndroid.getImagePathAndroid(), equals('assets/images/icon-710x599.png'));
expect(configAndroid.getImagePathIOS(), isNull);
final Map<String, dynamic> flutterIconsConfigBoth = <String, dynamic>{
'image_path_android': 'assets/images/icon-android.png',
Expand All @@ -129,8 +129,8 @@ flutter_icons:
'ios': true
};
final configBoth = FlutterLauncherIconsConfig.fromJson(flutterIconsConfigBoth);
expect(configBoth.getImagePathAndroid(), 'assets/images/icon-android.png');
expect(configBoth.getImagePathIOS(), 'assets/images/icon-ios.png');
expect(configBoth.getImagePathAndroid(), equals('assets/images/icon-android.png'));
expect(configBoth.getImagePathIOS(), equals('assets/images/icon-ios.png'));
});

test('At least one platform is in config file', () {
Expand All @@ -140,15 +140,15 @@ flutter_icons:
'ios': true
};
final config = FlutterLauncherIconsConfig.fromJson(flutterIconsConfig);
expect(config.hasPlatformConfig, true);
expect(config.hasPlatformConfig, isTrue);
});

test('No platform specified in config', () {
final Map<String, dynamic> flutterIconsConfig = <String, dynamic>{
'image_path': 'assets/images/icon-710x599.png'
};
final config = FlutterLauncherIconsConfig.fromJson(flutterIconsConfig);
expect(config.hasPlatformConfig, false);
expect(config.hasPlatformConfig, isFalse);
});

test('No new Android icon needed - android: false', () {
Expand All @@ -158,7 +158,7 @@ flutter_icons:
'ios': true
};
final config = FlutterLauncherIconsConfig.fromJson(flutterIconsConfig);
expect(config.isNeedingNewAndroidIcon, false);
expect(config.isNeedingNewAndroidIcon, isFalse);
});

test('No new Android icon needed - no Android config', () {
Expand All @@ -167,7 +167,7 @@ flutter_icons:
'ios': true
};
final config = FlutterLauncherIconsConfig.fromJson(flutterIconsConfig);
expect(config.isNeedingNewAndroidIcon, false);
expect(config.isNeedingNewAndroidIcon, isFalse);
});

test('No new iOS icon needed - ios: false', () {
Expand All @@ -177,7 +177,7 @@ flutter_icons:
'ios': false
};
final config = FlutterLauncherIconsConfig.fromJson(flutterIconsConfig);
expect(config.isNeedingNewIOSIcon, false);
expect(config.isNeedingNewIOSIcon, isFalse);
});

test('No new iOS icon needed - no iOS config', () {
Expand All @@ -186,6 +186,6 @@ flutter_icons:
'android': true
};
final config = FlutterLauncherIconsConfig.fromJson(flutterIconsConfig);
expect(config.isNeedingNewIOSIcon, false);
expect(config.isNeedingNewIOSIcon, isFalse);
});
}

0 comments on commit e2a077a

Please sign in to comment.