workspace_bloc_test.dart 895 B

123456789101112131415161718192021222324252627282930
  1. import 'package:app_flowy/startup/startup.dart';
  2. import 'package:app_flowy/workspace/application/workspace/welcome_bloc.dart';
  3. import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart';
  4. import 'package:flutter_test/flutter_test.dart';
  5. import 'package:bloc_test/bloc_test.dart';
  6. import 'util/test_env.dart';
  7. void main() {
  8. UserProfile? userInfo;
  9. setUpAll(() async {
  10. final flowyTest = await FlowyTest.setup();
  11. userInfo = await flowyTest.signIn();
  12. });
  13. group('WelcomeBloc', () {
  14. blocTest<WelcomeBloc, WelcomeState>(
  15. "create workspace",
  16. build: () => getIt<WelcomeBloc>(param1: userInfo),
  17. act: (bloc) {
  18. bloc.add(const WelcomeEvent.initial());
  19. },
  20. wait: const Duration(seconds: 2),
  21. verify: (bloc) {
  22. assert(bloc.state.isLoading == false);
  23. assert((bloc.state.workspaces.length) == 1);
  24. },
  25. );
  26. });
  27. }