haveSucceededWith function
- Object? outcomes
Matches a Result that is a Success with the given outcomes.
Accepts a single String or a List<String>, mirroring the Success constructor. Chain SuccessMatcher.andValue to also assert the value.
andValue accepts a plain value (compared with equals) or any
Matcher from package:matcher — allowing type checks, partial
attribute assertions, and any custom matcher:
expect(login, haveSucceededWith('ok'));
expect(login, haveSucceededWith(['ok', 'cached']));
// plain value
expect(login, haveSucceededWith('ok').andValue(alice));
// type check
expect(login, haveSucceededWith('ok').andValue(isA<UserSessionModel>()));
// type + attribute assertions
expect(
login,
haveSucceededWith('ok').andValue(
isA<UserSessionModel>()
.having((session) => session.user.name, 'name', 'Alice')
.having((session) => session.token, 'token', isNotEmpty),
),
);
Implementation
SuccessMatcher haveSucceededWith(Object? outcomes) => SuccessMatcher(_normalizeOutcomes(outcomes));