action_bloc_test 0.0.2+1 copy "action_bloc_test: ^0.0.2+1" to clipboard
action_bloc_test: ^0.0.2+1 copied to clipboard

Package to make creating tests for action_bloc easy.

example/lib/main.dart

import 'package:action_bloc/action_bloc.dart';
import 'package:action_bloc_test/action_bloc_test.dart';

class TestCubit extends ActionCubit<int, int> {
  TestCubit() : super(0);

  void increment() {
    emit(state + 1);

    if (state % 3 == 0) {
      emitAction(state);
    }
  }
}

void main() {
  actionBlocTest<TestCubit, int, int>(
    'test emit none',
    build: TestCubit.new,
    expectActions: () => <int>[],
  );

  final times = 30;

  actionBlocTest<TestCubit, int, int>(
    'test emit in order',
    build: TestCubit.new,
    act: (bloc) {
      for (var i = 0; i < times; i++) {
        bloc.increment();
      }
    },
    expect: () => <int>[for (var i = 1; i <= times; i++) i],
    expectActions: () => <int>[for (var i = 3; i <= times; i += 3) i],
  );
}
1
likes
130
pub points
0%
popularity

Publisher

unverified uploader

Package to make creating tests for action_bloc easy.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (LICENSE)

Dependencies

action_bloc, bloc_test, diff_match_patch, meta, test

More

Packages that depend on action_bloc_test