row_test.dart 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import 'package:app_flowy/plugins/grid/application/grid_bloc.dart';
  2. import 'package:flutter_test/flutter_test.dart';
  3. import 'package:bloc_test/bloc_test.dart';
  4. import 'util.dart';
  5. void main() {
  6. late AppFlowyGridTest gridTest;
  7. setUpAll(() async {
  8. gridTest = await AppFlowyGridTest.ensureInitialized();
  9. });
  10. group('GridBloc', () {
  11. blocTest<GridBloc, GridState>(
  12. "Create row",
  13. build: () =>
  14. GridBloc(view: gridTest.gridView)..add(const GridEvent.initial()),
  15. act: (bloc) => bloc.add(const GridEvent.createRow()),
  16. wait: const Duration(milliseconds: 300),
  17. verify: (bloc) {
  18. assert(bloc.state.rowInfos.length == 4);
  19. },
  20. );
  21. });
  22. group('GridBloc', () {
  23. late GridBloc gridBloc;
  24. setUpAll(() async {
  25. gridBloc = GridBloc(view: gridTest.gridView)
  26. ..add(const GridEvent.initial());
  27. await gridBlocResponseFuture();
  28. });
  29. // The initial number of rows is three
  30. test('', () async {
  31. assert(gridBloc.state.rowInfos.length == 3);
  32. });
  33. test('delete row', () async {
  34. gridBloc.add(GridEvent.deleteRow(gridBloc.state.rowInfos.last));
  35. await gridBlocResponseFuture();
  36. assert(gridBloc.state.rowInfos.length == 2);
  37. });
  38. });
  39. }