neverEmits method
Expects that the stream closes without emitting any event that satisfies
condition.
Returns a Future that completes after the stream has closed.
Fails if the stream emits any even that satisfies condition.
If this expectation fails, the source queue will be left in its original
state.
If this expectation succeeds, consumes all the events that did not satisfy
condition until the end of the stream.
Implementation
@awaitNotRequired
Future<void> neverEmits(AsyncCondition<T> condition) async {
await _expectAsync(
() => ['never emits a value that:', ...describe(condition)],
(actual) async {
var count = 0;
await for (var emitted in actual.rest) {
if (softCheck(emitted, condition) == null) {
return Rejection(
actual: ['a stream'],
which: [
...prefixFirst('emitted ', literal(emitted)),
if (count > 0) 'following $count other items',
],
);
}
count++;
}
return null;
},
);
}