From 2accf9f2b3fc332c5062bbae350373853a87972d Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Sun, 3 Nov 2024 18:05:17 +0100 Subject: [PATCH] covered films model `updateShouldNotifyDependent` --- test/providers/films_provider_test.dart | 62 +++++++++++++++++++++---- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/test/providers/films_provider_test.dart b/test/providers/films_provider_test.dart index 9f659fd..d9de6a3 100644 --- a/test/providers/films_provider_test.dart +++ b/test/providers/films_provider_test.dart @@ -50,19 +50,19 @@ void main() { } void expectPredefinedFilmsCount(int count) { - expect(find.text('Predefined films count: $count'), findsOneWidget); + expect(find.text(_PredefinedFilmsCount.text(count)), findsOneWidget); } void expectCustomFilmsCount(int count) { - expect(find.text('Custom films count: $count'), findsOneWidget); + expect(find.text(_CustomFilmsCount.text(count)), findsOneWidget); } void expectFilmsInUseCount(int count) { - expect(find.text('Films in use count: $count'), findsOneWidget); + expect(find.text(_FilmsInUseCount.text(count)), findsOneWidget); } void expectSelectedFilmName(String name) { - expect(find.text('Selected film: $name'), findsOneWidget); + expect(find.text(_SelectedFilm.text(name)), findsOneWidget); } group( @@ -234,15 +234,15 @@ class _Application extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp( + return const MaterialApp( home: Scaffold( body: Center( child: Column( children: [ - Text("Predefined films count: ${Films.predefinedFilmsOf(context).length}"), - Text("Custom films count: ${Films.customFilmsOf(context).length}"), - Text("Films in use count: ${Films.inUseOf(context).length}"), - Text("Selected film: ${Films.selectedOf(context).name}"), + _PredefinedFilmsCount(), + _CustomFilmsCount(), + _FilmsInUseCount(), + _SelectedFilm(), ], ), ), @@ -251,6 +251,50 @@ class _Application extends StatelessWidget { } } +class _PredefinedFilmsCount extends StatelessWidget { + static String text(int count) => "Predefined films count: $count"; + + const _PredefinedFilmsCount(); + + @override + Widget build(BuildContext context) { + return Text(text(Films.predefinedFilmsOf(context).length)); + } +} + +class _CustomFilmsCount extends StatelessWidget { + static String text(int count) => "Custom films count: $count"; + + const _CustomFilmsCount(); + + @override + Widget build(BuildContext context) { + return Text(text(Films.customFilmsOf(context).length)); + } +} + +class _FilmsInUseCount extends StatelessWidget { + static String text(int count) => "Films in use count: $count"; + + const _FilmsInUseCount(); + + @override + Widget build(BuildContext context) { + return Text(text(Films.inUseOf(context).length)); + } +} + +class _SelectedFilm extends StatelessWidget { + static String text(String name) => "Selected film: $name}"; + + const _SelectedFilm(); + + @override + Widget build(BuildContext context) { + return Text(text(Films.selectedOf(context).name)); + } +} + const mockPredefinedFilms = [ FilmExponential(id: '1', name: 'Mock film 2x', iso: 400, exponent: 1.34), FilmExponential(id: '2', name: 'Mock film 3x', iso: 800, exponent: 1.34),