Skip to content

Commit

Permalink
fix(generator): fixed typo in a method
Browse files Browse the repository at this point in the history
  • Loading branch information
RatakondalaArun committed Jul 20, 2022
1 parent 4fac239 commit 4aa4162
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 29 deletions.
4 changes: 2 additions & 2 deletions lib/abs/icon_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class IconGenerator {
/// Should return `true` if this platform
/// has all the requirments to create icons.
/// This runs before to [createIcons]
bool validateRequirments();
bool validateRequirements();
}

/// Provides easy access to user arguments and configuration
Expand Down Expand Up @@ -63,7 +63,7 @@ void generateIconsFor({
logger.verbose('Validating platform requirments for ${platform.platformName}');
// in case a platform throws an exception it should not effect other platforms
try {
if (!platform.validateRequirments()) {
if (!platform.validateRequirements()) {
logger.error('Requirments failed for platform ${platform.platformName}. Skipped');
progress.cancel();
continue;
Expand Down
2 changes: 1 addition & 1 deletion lib/web/web_icon_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class WebIconGenerator extends IconGenerator {
}

@override
bool validateRequirments() {
bool validateRequirements() {
// check if web config exists
context.logger.verbose('Checking webconfig...');
final webConfig = context.webConfig;
Expand Down
12 changes: 6 additions & 6 deletions test/abs/icon_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,33 @@ void main() {
));
});
test('should execute createIcons() when validateRequiremnts() returns true', () {
when(mockGenerator.validateRequirments()).thenReturn(true);
when(mockGenerator.validateRequirements()).thenReturn(true);
generateIconsFor(
config: mockFLIConfig,
flavor: null,
prefixPath: prefixPath,
logger: logger,
platforms: (context) => [mockGenerator],
);
verify(mockGenerator.validateRequirments()).called(equals(1));
verify(mockGenerator.validateRequirements()).called(equals(1));
verify(mockGenerator.createIcons()).called(equals(1));
});

test('should not execute createIcons() when validateRequiremnts() returns false', () {
when(mockGenerator.validateRequirments()).thenReturn(false);
when(mockGenerator.validateRequirements()).thenReturn(false);
generateIconsFor(
config: mockFLIConfig,
flavor: null,
prefixPath: prefixPath,
logger: logger,
platforms: (context) => [mockGenerator],
);
verify(mockGenerator.validateRequirments()).called(equals(1));
verify(mockGenerator.validateRequirements()).called(equals(1));
verifyNever(mockGenerator.createIcons());
});

test('should skip platform if any exception occured', () {
when(mockGenerator.validateRequirments()).thenReturn(true);
when(mockGenerator.validateRequirements()).thenReturn(true);
when(mockGenerator.createIcons()).thenThrow(Exception('should-skip-platform'));
generateIconsFor(
config: mockFLIConfig,
Expand All @@ -64,7 +64,7 @@ void main() {
logger: logger,
platforms: (context) => [mockGenerator],
);
verify(mockGenerator.validateRequirments()).called(equals(1));
verify(mockGenerator.validateRequirements()).called(equals(1));
verify(mockGenerator.createIcons()).called(equals(1));
expect(() => mockGenerator.createIcons(), throwsException);
});
Expand Down
30 changes: 11 additions & 19 deletions test/abs/icon_generator_test.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// Do not manually edit this file.

import 'package:flutter_launcher_icons/abs/icon_generator.dart' as _i2;
import 'package:flutter_launcher_icons/flutter_launcher_icons_config.dart'
as _i3;
import 'package:flutter_launcher_icons/flutter_launcher_icons_config.dart' as _i3;
import 'package:mockito/mockito.dart' as _i1;

// ignore_for_file: type=lint
Expand All @@ -17,22 +16,19 @@ import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types

class _FakeIconGeneratorContext_0 extends _i1.Fake
implements _i2.IconGeneratorContext {}
class _FakeIconGeneratorContext_0 extends _i1.Fake implements _i2.IconGeneratorContext {}

/// A class which mocks [FlutterLauncherIconsConfig].
///
/// See the documentation for Mockito's code generation for more information.
class MockFlutterLauncherIconsConfig extends _i1.Mock
implements _i3.FlutterLauncherIconsConfig {
class MockFlutterLauncherIconsConfig extends _i1.Mock implements _i3.FlutterLauncherIconsConfig {
MockFlutterLauncherIconsConfig() {
_i1.throwOnMissingStub(this);
}

@override
Map<String, dynamic> toJson() =>
(super.noSuchMethod(Invocation.method(#toJson, []),
returnValue: <String, dynamic>{}) as Map<String, dynamic>);
(super.noSuchMethod(Invocation.method(#toJson, []), returnValue: <String, dynamic>{}) as Map<String, dynamic>);
}

/// A class which mocks [IconGenerator].
Expand All @@ -44,18 +40,14 @@ class MockIconGenerator extends _i1.Mock implements _i2.IconGenerator {
}

@override
_i2.IconGeneratorContext get context => (super.noSuchMethod(
Invocation.getter(#context),
returnValue: _FakeIconGeneratorContext_0()) as _i2.IconGeneratorContext);
_i2.IconGeneratorContext get context =>
(super.noSuchMethod(Invocation.getter(#context), returnValue: _FakeIconGeneratorContext_0())
as _i2.IconGeneratorContext);
@override
String get platformName =>
(super.noSuchMethod(Invocation.getter(#platformName), returnValue: '')
as String);
String get platformName => (super.noSuchMethod(Invocation.getter(#platformName), returnValue: '') as String);
@override
void createIcons() => super.noSuchMethod(Invocation.method(#createIcons, []),
returnValueForMissingStub: null);
void createIcons() => super.noSuchMethod(Invocation.method(#createIcons, []), returnValueForMissingStub: null);
@override
bool validateRequirments() =>
(super.noSuchMethod(Invocation.method(#validateRequirments, []),
returnValue: false) as bool);
bool validateRequirements() =>
(super.noSuchMethod(Invocation.method(#validateRequirments, []), returnValue: false) as bool);
}
2 changes: 1 addition & 1 deletion test/web/web_icon_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void main() {

// end to end test
test('should generate valid icons', () async {
expect(generator.validateRequirments(), isTrue);
expect(generator.validateRequirements(), isTrue);
generator.createIcons();
await expectLater(
d.dir('fli_test', [
Expand Down

0 comments on commit 4aa4162

Please sign in to comment.