Skip to content

Commit

Permalink
test: very_good_flutter_plugin doesn't have full code coverage (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfenrain committed Apr 4, 2024
1 parent 0d99b59 commit f44a80c
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ class CheckPlatformName extends Action {
String description() => 'Check platform name: "$_expectedPlatformName"';
}

// coverage:ignore-start these are just wrappers for overloading
bool _platformIsAndroid() => Platform.isAndroid;
bool _platformIsIOS() => Platform.isIOS;
bool _platformIsLinux() => Platform.isLinux;
bool _platformIsMacOS() => Platform.isMacOS;
bool _platformIsWindows() => Platform.isWindows;
// coverage:ignore-end
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,98 @@ void main() {
expect(await action.execute(tester), isFalse);
});

test('show correct description', () {
test('show correct description for every platform', () {
bool isTrue() => true;
bool isFalse() => false;

final testCases = [
(
'Android',
CheckPlatformName(
isAndroid: isTrue,
isIOS: isFalse,
isWeb: isFalse(),
isWindows: isFalse,
isLinux: isFalse,
isMacOS: isFalse,
)
),
(
'iOS',
CheckPlatformName(
isAndroid: isFalse,
isIOS: isTrue,
isWeb: isFalse(),
isWindows: isFalse,
isLinux: isFalse,
isMacOS: isFalse,
)
),
(
'Web',
CheckPlatformName(
isAndroid: isFalse,
isIOS: isFalse,
isWeb: isTrue(),
isWindows: isFalse,
isLinux: isFalse,
isMacOS: isFalse,
)
),
(
'Linux',
CheckPlatformName(
isAndroid: isFalse,
isIOS: isFalse,
isWeb: isFalse(),
isWindows: isFalse,
isLinux: isTrue,
isMacOS: isFalse,
)
),
(
'MacOS',
CheckPlatformName(
isAndroid: isFalse,
isIOS: isFalse,
isWeb: isFalse(),
isWindows: isFalse,
isLinux: isFalse,
isMacOS: isTrue,
)
),
(
'Windows',
CheckPlatformName(
isAndroid: isFalse,
isIOS: isFalse,
isWeb: isFalse(),
isWindows: isTrue,
isLinux: isFalse,
isMacOS: isFalse,
)
),
];

for (final testCase in testCases) {
expect(
testCase.$2.description(),
equals('Check platform name: "${testCase.$1}"'),
);
}
});

test('throws UnsupportedError on unknown platform', () {
final action = CheckPlatformName(
isAndroid: () => true,
isAndroid: () => false,
isIOS: () => false,
isWeb: false,
isWindows: () => false,
isLinux: () => false,
isMacOS: () => false,
isWindows: () => false,
);

expect(
action.description(),
equals('Check platform name: "Android"'),
);
expect(action.description, throwsUnsupportedError);
});
});
}

0 comments on commit f44a80c

Please sign in to comment.