completes method

Future<void> completes([
  1. AsyncCondition<T>? completionCondition
])

Expects that the Future completes to a value without throwing.

Fails if the future completes as an error.

Pass completionCondition to check expectations on the completion result.

The returned future will complete when the subject future has completed, and completionCondition has optionally been checked.

Implementation

Future<void> completes([AsyncCondition<T>? completionCondition]) async {
  await context.nestAsync<T>(() => ['completes to a value'], (actual) async {
    try {
      return Extracted.value(await actual);
    } catch (e, st) {
      return Extracted.rejection(actual: [
        'a future that completes as an error'
      ], which: [
        ...prefixFirst('threw ', postfixLast(' at:', literal(e))),
        ...const LineSplitter().convert(st.toString())
      ]);
    }
  }, completionCondition);
}