dart format
This commit is contained in:
@@ -14,27 +14,33 @@ void main() {
|
||||
seenBusyInsideCallback = controller.busy;
|
||||
});
|
||||
|
||||
expect(seenBusyInsideCallback, isTrue,
|
||||
reason: 'busy must be true while the callback is running');
|
||||
expect(
|
||||
seenBusyInsideCallback,
|
||||
isTrue,
|
||||
reason: 'busy must be true while the callback is running',
|
||||
);
|
||||
expect(ok, isTrue);
|
||||
expect(controller.busy, isFalse);
|
||||
expect(controller.error, isNull);
|
||||
});
|
||||
|
||||
test('captures mapped error message on failure and returns false', () async {
|
||||
final controller = AsyncActionController();
|
||||
addTearDown(controller.dispose);
|
||||
test(
|
||||
'captures mapped error message on failure and returns false',
|
||||
() async {
|
||||
final controller = AsyncActionController();
|
||||
addTearDown(controller.dispose);
|
||||
|
||||
final ok = await controller.run(
|
||||
() async => throw Exception('boom'),
|
||||
errorBuilder: (e) => 'custom: $e',
|
||||
);
|
||||
final ok = await controller.run(
|
||||
() async => throw Exception('boom'),
|
||||
errorBuilder: (e) => 'custom: $e',
|
||||
);
|
||||
|
||||
expect(ok, isFalse);
|
||||
expect(controller.busy, isFalse);
|
||||
expect(controller.error, contains('custom:'));
|
||||
expect(controller.error, contains('boom'));
|
||||
});
|
||||
expect(ok, isFalse);
|
||||
expect(controller.busy, isFalse);
|
||||
expect(controller.error, contains('custom:'));
|
||||
expect(controller.error, contains('boom'));
|
||||
},
|
||||
);
|
||||
|
||||
test('rejects re-entry while busy', () async {
|
||||
final controller = AsyncActionController();
|
||||
@@ -51,8 +57,12 @@ void main() {
|
||||
expect(controller.busy, isTrue);
|
||||
|
||||
final reentrant = await controller.run(() async {});
|
||||
expect(reentrant, isFalse,
|
||||
reason: 'second run while busy must be rejected without invoking callback');
|
||||
expect(
|
||||
reentrant,
|
||||
isFalse,
|
||||
reason:
|
||||
'second run while busy must be rejected without invoking callback',
|
||||
);
|
||||
|
||||
firstCanFinish.complete();
|
||||
expect(await firstFuture, isTrue);
|
||||
|
||||
Reference in New Issue
Block a user