Created
July 21, 2019 14:12
-
-
Save SAGARSURI/486ee3797c28ec263ff92dae3dd91bf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:inject/inject.dart'; | |
import 'package:my_movies/src/blocs/movies_bloc.dart'; | |
import 'package:my_movies/src/blocs/movie_detail_bloc.dart'; | |
import 'package:my_movies/src/models/item_model.dart'; | |
import 'package:my_movies/src/models/trailer_model.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:my_movies/src/di/bloc_injector.dart'; | |
import 'package:my_movies/src/di/bloc_module.dart'; | |
void main() async { | |
group("BloC testing", (){ | |
test("Movie BLoC testing", () async { | |
var container = await BlocInjector.create(BlocModule()); | |
var moviesBloc = container.app.moviesBloc; | |
moviesBloc.init(); | |
moviesBloc.fetchAllMovies(); | |
moviesBloc.allMovies.listen(expectAsync1((value){ | |
expect(value, isInstanceOf<ItemModel>()); | |
})); | |
}); | |
test("Movie Detail BLoC testing", () async { | |
var container = await BlocInjector.create(BlocModule()); | |
var moviesBloc = container.app.movieDetailBloc; | |
moviesBloc.init(); | |
moviesBloc.fetchTrailersById(420818); | |
moviesBloc.movieTrailers.listen(expectAsync1((value){ | |
expect(value, isInstanceOf<TrailerModel>()); | |
})); | |
}); | |
}); | |
} | |
class BlocTest{ | |
final MoviesBloc moviesBloc; | |
final MovieDetailBloc movieDetailBloc; | |
@provide | |
BlocTest(this.moviesBloc, this.movieDetailBloc): super(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment