-
Notifications
You must be signed in to change notification settings - Fork 3
test: improve test coverage for key modules #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
26d5fbc
6ed5165
cbcc4ce
bb068b9
af2fff5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,4 +21,5 @@ dependencies: | |
| dev_dependencies: | ||
| dart_code_metrics_presets: ^2.19.0 | ||
| lints: ^5.0.0 | ||
| mocktail: ^1.0.4 | ||
| test: ^1.25.8 | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,251 @@ | ||||||||||||||||||||||||
| import 'dart:io'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import 'package:args/command_runner.dart'; | ||||||||||||||||||||||||
|
Check warning on line 3 in packages/cli/test/src/commands/build_command_test.dart
|
||||||||||||||||||||||||
| import 'package:mason_logger/mason_logger.dart'; | ||||||||||||||||||||||||
| import 'package:path/path.dart' as path; | ||||||||||||||||||||||||
| import 'package:superdeck_cli/src/commands/build_command.dart'; | ||||||||||||||||||||||||
| import 'package:test/test.dart'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import '../testing_utils.dart'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| void main() { | ||||||||||||||||||||||||
| group('BuildCommand', () { | ||||||||||||||||||||||||
| late BuildCommand command; | ||||||||||||||||||||||||
| late Directory tempDir; | ||||||||||||||||||||||||
| late Directory previousDir; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| setUp(() async { | ||||||||||||||||||||||||
| tempDir = await createTempDirAsync(); | ||||||||||||||||||||||||
| command = BuildCommand(); | ||||||||||||||||||||||||
| previousDir = Directory.current; | ||||||||||||||||||||||||
| Directory.current = tempDir; | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| tearDown(() { | ||||||||||||||||||||||||
| Directory.current = previousDir; | ||||||||||||||||||||||||
|
Comment on lines
+24
to
+25
|
||||||||||||||||||||||||
| tearDown(() { | |
| Directory.current = previousDir; | |
| tearDown(() async { | |
| Directory.current = previousDir; | |
| try { | |
| if (await tempDir.exists()) { | |
| await tempDir.delete(recursive: true); | |
| } | |
| } catch (_) { | |
| // Best-effort cleanup; ignore failures (e.g., due to file locks). | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,9 +5,21 @@ import 'package:mix/mix.dart'; | |||||||
|
|
||||||||
| import 'styling.dart'; | ||||||||
|
|
||||||||
| /// Safely loads a Google Font, falling back to platform default when runtime | ||||||||
| /// fetching is disabled (e.g., in tests). | ||||||||
| TextStyle _safeGoogleFont(TextStyle Function() fontLoader) { | ||||||||
| // When runtime fetching is disabled (typically in tests), Google Fonts | ||||||||
| // requires bundled font assets. Since we don't bundle fonts for tests, | ||||||||
| // use platform default instead. | ||||||||
| if (!GoogleFonts.config.allowRuntimeFetching) { | ||||||||
| return const TextStyle(); | ||||||||
| } | ||||||||
| return fontLoader(); | ||||||||
| } | ||||||||
|
|
||||||||
| // Base text style for the presentation | ||||||||
| TextStyle get _baseTextStyle => | ||||||||
| GoogleFonts.poppins().copyWith(fontSize: 24, color: Colors.white); | ||||||||
| _safeGoogleFont(GoogleFonts.poppins).copyWith(fontSize: 24, color: Colors.white); | ||||||||
|
||||||||
| _safeGoogleFont(GoogleFonts.poppins).copyWith(fontSize: 24, color: Colors.white); | |
| _safeGoogleFont(() => GoogleFonts.poppins()) | |
| .copyWith(fontSize: 24, color: Colors.white); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
mocktaildependency is added inpubspec.yamlbut is not used in any of the new test files in this PR. Consider removing this dependency if it's not needed, or if it's intended for future use, add a comment in the pubspec explaining its purpose.