Skip to content

Commit

Permalink
Add tests for closing
Browse files Browse the repository at this point in the history
  • Loading branch information
WezSieTato committed Dec 29, 2024
1 parent 6a908ff commit 0d65432
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/scan_bloc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,62 @@ void main() {
],
);

blocTest(
'emits close remote button should remove button',
build: () => _scanBloc(),
act: (bloc) {
bloc.add(ScanEvent.barcodeScanned("button1"));
bloc.add(ScanEvent.closeRemoteButton());
},
expect: () => [
ScanState(isLoading: true),
ScanState(
list: [_testSearchResultWithButton("button1")],
isLoading: false,
remoteButtonState: _remoteStateButton("button1")),
ScanState(
list: [_testSearchResultWithButton("button1")],
isLoading: false,
remoteButtonState: null,
wasRemoteButtonClosed: true),
],
);

blocTest(
'emits close remote button should block appearing remote button',
build: () => _scanBloc(),
act: (bloc) {
bloc.add(ScanEvent.barcodeScanned("button1"));
bloc.add(ScanEvent.closeRemoteButton());
bloc.add(ScanEvent.barcodeScanned("button2"));
},
expect: () => [
ScanState(isLoading: true),
ScanState(
list: [_testSearchResultWithButton("button1")],
isLoading: false,
remoteButtonState: _remoteStateButton("button1")),
ScanState(
list: [_testSearchResultWithButton("button1")],
isLoading: false,
remoteButtonState: null,
wasRemoteButtonClosed: true),
ScanState(
list: [_testSearchResultWithButton("button1")],
isLoading: true,
remoteButtonState: null,
wasRemoteButtonClosed: true),
ScanState(
list: [
_testSearchResultWithButton("button1"),
_testSearchResultWithButton("button2")
],
isLoading: false,
remoteButtonState: null,
wasRemoteButtonClosed: true),
],
);

blocTest(
'emits state with error when scanned barcode results in error',
build: () => _scanBloc(),
Expand Down

0 comments on commit 0d65432

Please sign in to comment.