-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #752 from Prime-Holding/develop
rx_bloc_cli-v3.8.0
- Loading branch information
Showing
14 changed files
with
193 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
### Smart Widgets dependencies for Golden Tests | ||
|
||
In golden tests we want to mock the BLoCs to be able to test all UI states. By using smart widgets that manage their dependencies, golden tests could fail. To fix this issue we need to build the smart widgets without injecting the required components during the test. This is why we added `isInTestMode` in `app_constants.dart`. | ||
|
||
To use it in custom widgets with their own dependency injection you can follow this example: | ||
``` | ||
import '../../base/app/config/app_constants.dart'; | ||
... | ||
class AppTodoListBulkEditPopupMenuButtonWithDependencies { | ||
@override | ||
Widget build(BuildContext context) { | ||
final current = TodoManagementPage(); | ||
if(isInTestMode) { | ||
return current; | ||
} | ||
return MultiProvider( | ||
providers: [ | ||
..._services, | ||
..._blocs, | ||
], | ||
child: current, | ||
); | ||
} | ||
} | ||
``` | ||
> [!CAUTION] | ||
> You should import `isInTestMode` from [app_constants.dart]! | ||
> Since we don't want to add dependency on `universal_io/io.dart`, because we want to avoid the additional maintenance cost, we check if `dart.library.io` is available to determine if we are running a test or other environment. | ||
*app_constants.dart* | ||
``` | ||
export 'is_in_test_mode_io_not_available.dart' if (dart.library.io) 'is_in_test_mode_io_available.dart' if (dart.library.html) 'is_in_test_mode_io_not_available.dart'; | ||
``` | ||
*is_in_test_mode_io_available.dart* | ||
``` | ||
import 'dart:io'; | ||
bool isInTestMode = Platform.environment.containsKey('FLUTTER_TEST'); | ||
``` | ||
|
||
*is_in_test_mode_io_not_available.dart* | ||
``` | ||
const bool isInTestMode = false; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.