side_effect_cubit_test 1.0.2 copy "side_effect_cubit_test: ^1.0.2" to clipboard
side_effect_cubit_test: ^1.0.2 copied to clipboard

This is a testing utility designed to simplify the process of testing Blocs that produce side effects. It builds upon the bloc_test package and introduces features that allow developers to expect side [...]

example/main.dart

import "package:side_effect_cubit_test/side_effect_cubit_test.dart";
import "package:side_effect_cubit/side_effect_cubit.dart";
import "package:test/test.dart";

class CounterCubit extends SideEffectCubit<int, CounterSideEffect> {
  CounterCubit() : super(0);

  void plusOne() {
    produceSideEffect(ShowInfoDialogEffect());
    emit(state + 1);
  }
}

abstract class CounterSideEffect {}

class ShowInfoDialogEffect extends CounterSideEffect {}

void main() {
  final counterCubit = CounterCubit();

  group("side_effect tests", () {
    sideEffectBlocTest<CounterCubit, int, CounterSideEffect>(
      "plusOne should yield ShowInfoDialogEffect",
      build: () => counterCubit,
      act: (cubit) => cubit.plusOne(),
      expect: () => [1],
      expectSideEffects: () => [isA<ShowInfoDialogEffect>()],
    );
  });
}
0
likes
120
pub points
0%
popularity

Publisher

verified publishersontieu.dev

This is a testing utility designed to simplify the process of testing Blocs that produce side effects. It builds upon the bloc_test package and introduces features that allow developers to expect side effects to be emitted

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

bloc, diff_match_patch, meta, mocktail, side_effect_cubit, test

More

Packages that depend on side_effect_cubit_test