File tree 4 files changed +24
-3
lines changed
4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change
1
+ ## 3.0.1
2
+
3
+ * fix: track was not ended when behaviour resulted in a future
4
+
1
5
## 3.0.0
2
6
3
7
* feat!: upgraded to dart v3
Original file line number Diff line number Diff line change @@ -55,7 +55,9 @@ mixin BehaviourMixin {
55
55
BehaviourTrack ? track,
56
56
) async {
57
57
try {
58
- return await future;
58
+ final result = await future;
59
+ track? .end ();
60
+ return result;
59
61
} catch (error, stackTrace) {
60
62
return _catch (error, stackTrace, track);
61
63
}
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ name: behaviour
2
2
description :
3
3
This package adds support for behaviours. Behaviours are classes of which the
4
4
instances are used as functions.
5
- version : 3.0.0
5
+ version : 3.0.1
6
6
repository : https://github.com/wim07101993/behaviour
7
7
8
8
environment :
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ void main() {
89
89
});
90
90
});
91
91
92
- test ('should start and end the track' , () async {
92
+ test ('should start and end the track in case of sync ' , () async {
93
93
// act
94
94
await behaviour.executeAction ((track) => const Success (Object ()));
95
95
@@ -102,6 +102,21 @@ void main() {
102
102
verifyNever (() => mockTrack.stopWithException (any (), any ()));
103
103
});
104
104
105
+ test ('should start and end the track in case of future' , () async {
106
+ // act
107
+ await behaviour.executeAction (
108
+ (track) => Future .value (const Success (Object ())),
109
+ );
110
+
111
+ // assert
112
+ verifyInOrder ([
113
+ () => mockTrack.start (),
114
+ () => mockTrack.end (),
115
+ ]);
116
+ verifyNever (() => mockTrack.stopWithError (any (), any ()));
117
+ verifyNever (() => mockTrack.stopWithException (any (), any ()));
118
+ });
119
+
105
120
test ('should execute and return result of action' , () async {
106
121
// arrange
107
122
final expected = faker.randomGenerator.element <ExceptionOr <String >>([
You can’t perform that action at this time.
0 commit comments