Skip to content

Commit

Permalink
test : added tests for `lib/view_model/widgets_view_models/progress_d…
Browse files Browse the repository at this point in the history
…ialog_view_model.dart` (#2670)

* added new tests cases for the ProgressDialogViewModel to enhance testing coverage

* Changes Made as per the nitpick comments to enhance readability

---------

Co-authored-by: Satyam Jha <[email protected]>
  • Loading branch information
may-tas and Satyam Jha authored Dec 21, 2024
1 parent 6060260 commit db0d597
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions test/view_model_tests/progress_dialog_view_model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,35 @@ import '../helpers/test_helpers.dart';
void main() {
group('ProgressDialogViewModelTest -', () {
group('initialise -', () {
getAndRegisterConnectivity();
AppConnectivity.isOnline = true;

final model = ProgressDialogViewModel();
setUp(() {
getAndRegisterConnectivity();
});

test(
'When called and connectivity is present, connectivityPresent must be set to true',
() async {
// Simulate online state
AppConnectivity.isOnline = true;

final model = ProgressDialogViewModel();

await model.initialise();

expect(model.connectivityPresent, true);
});

test(
'When called and connectivity is absent, connectivityPresent must be set to false',
() async {
// Simulate offline state
AppConnectivity.isOnline = false;

final model = ProgressDialogViewModel();

await model.initialise();

expect(model.connectivityPresent, false);
});
});
});
}

0 comments on commit db0d597

Please sign in to comment.