Skip to content

Commit

Permalink
fix mock, and refactor per code review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
codinesh committed Dec 28, 2023
1 parent 3d8d813 commit c7688a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/app_center/lib/src/manage/manage_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ class _ActionButtons extends ConsumerWidget {
error: (_, __) => ('', const SizedBox.shrink()),
);

final updatesInprogress = updatesModel.refreshableSnapNames.isNotEmpty &&
!updatesModel.state.isLoading &&
updatesModel.activeChangeId != null;
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down Expand Up @@ -306,9 +309,7 @@ class _ActionButtons extends ConsumerWidget {
),
const SizedBox(width: 8),
PushButton.outlined(
onPressed: updatesModel.refreshableSnapNames.isNotEmpty &&
!updatesModel.state.isLoading &&
updatesModel.activeChangeId != null
onPressed: updatesInprogress
? () => ref
.read(updatesModelProvider)
.cancelChange(updatesModel.activeChangeId!)
Expand Down
10 changes: 10 additions & 0 deletions packages/app_center/test/test_utils.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,16 @@ class MockUpdatesModel extends _i1.Mock implements _i6.UpdatesModel {
returnValueForMissingStub: _i14.Future<void>.value(),
) as _i14.Future<void>);

@override
_i14.Future<void> cancelChange(String? changeId) => (super.noSuchMethod(
Invocation.method(
#cancelChange,
[changeId],
),
returnValue: _i14.Future<void>.value(),
returnValueForMissingStub: _i14.Future<void>.value(),
) as _i14.Future<void>);

@override
void addListener(_i15.VoidCallback? listener) => super.noSuchMethod(
Invocation.method(
Expand Down

0 comments on commit c7688a3

Please sign in to comment.