Last updated:
0 purchases
mocktailx
mocktailx #
A set of utility functions for mocktail apis.
Usage #
First import mocktailx to your pubspec:
mocktailx: ^latest version here
copied to clipboard
Note that this library is a container for mocktail, so you don't need to import mocktail.
And don't forget to fix your imports:
import 'package:mocktailx/mocktailx.dart';
copied to clipboard
Features #
thenAnswerWithVoid
// Instead of doing:
when(repo.futureVoidFunction).thenAnswer((invocation) async {});
// You can just:
when(repo.futureVoidFunction).thenAnswerWithVoid();
copied to clipboard
thenAnswerWith(T)
// Instead of doing:
when(repo.futureIntFunction).thenAnswer((invocation) async => 10);
// You can just:
when(repo.futureIntFunction).thenAnswerWith(10);
copied to clipboard
thenAnswerInOrder(List<Answer
// Instead of doing:
final List<Future<int> Function(Invocation)> answers = [
(_) async => 6,
(_) async => 7,
(_) async => 99,
];
when(() => repo.asyncInteger()).thenAnswer((invocation) => answers.removeAt(0)(invocation));
// You can just:
when(() => repo.asyncInteger()).thenAnswerInOrder([
(invocation) async => 6,
(_) async => 7,
(_) async => 99,
]);
copied to clipboard
thenEmit(List)
// Instead of doing:
when(repo.streamValue).thenAnswer((invocation) => Stream.fromIterable([1,2,3,4,5]));
// You can just:
when(repo.streamValue).thenEmit([1,2,3,4,5]);
copied to clipboard
thenReturnWithVoid
// Instead of doing:
when(repo.voidFunction).thenReturn(null);
// You can just:
when(repo.voidFunction).thenReturnWithVoid();
copied to clipboard
thenReturnInOrder(List
// Instead of doing:
when(() => repo.addOne(1)).thenReturn(6);
when(() => repo.addOne(2)).thenReturn(7);
when(() => repo.addOne(3)).thenReturn(99);
// You can just:
when(() => repo.addOne(any())).thenReturnInOrder([6, 7, 99]);
copied to clipboard
// Instead of doing:
final answers = [6, 7, 99];
when(() => repo.addOne(1)).thenAnswer((invocation) => answers.removeAt(0));
// You can just:
when(() => repo.addOne(1)).thenReturnInOrder([6, 7, 99]);
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.