From cf42796eb220d46a43d80d41d38d3004d6b26d52 Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Sun, 28 Jul 2024 15:45:08 -0500 Subject: [PATCH] refactor(flutter_bloc_with_stream): improve test descriptions --- examples/flutter_bloc_with_stream/test/app_test.dart | 4 ++-- .../test/bloc/ticker_bloc_test.dart | 12 ++++++------ .../test/bloc/ticker_event_test.dart | 4 ++-- .../test/bloc/ticker_state_test.dart | 8 ++++---- .../test/ticker_page_test.dart | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/flutter_bloc_with_stream/test/app_test.dart b/examples/flutter_bloc_with_stream/test/app_test.dart index bae6274a09b..7bcc1170918 100644 --- a/examples/flutter_bloc_with_stream/test/app_test.dart +++ b/examples/flutter_bloc_with_stream/test/app_test.dart @@ -3,12 +3,12 @@ import 'package:flutter_bloc_with_stream/main.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - group('TickerApp', () { + group(TickerApp, () { testWidgets('is a MaterialApp', (tester) async { expect(TickerApp(), isA()); }); - testWidgets('renders TickerPage', (tester) async { + testWidgets('renders $TickerPage', (tester) async { await tester.pumpWidget(TickerApp()); expect(find.byType(TickerPage), findsOneWidget); }); diff --git a/examples/flutter_bloc_with_stream/test/bloc/ticker_bloc_test.dart b/examples/flutter_bloc_with_stream/test/bloc/ticker_bloc_test.dart index 1db300b5a94..0556229cb41 100644 --- a/examples/flutter_bloc_with_stream/test/bloc/ticker_bloc_test.dart +++ b/examples/flutter_bloc_with_stream/test/bloc/ticker_bloc_test.dart @@ -6,20 +6,20 @@ import 'package:flutter_bloc_with_stream/ticker/ticker.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; -class MockTicker extends Mock implements Ticker {} +class _MockTicker extends Mock implements Ticker {} void main() { - group('TickerBloc', () { + group(TickerBloc, () { late Ticker ticker; setUp(() { - ticker = MockTicker(); + ticker = _MockTicker(); when(ticker.tick).thenAnswer( (_) => Stream.fromIterable([1, 2, 3]), ); }); - test('initial state is TickerInitial', () { + test('initial state is $TickerInitial', () { expect(TickerBloc(ticker).state, TickerInitial()); }); @@ -30,7 +30,7 @@ void main() { ); blocTest( - 'emits TickerTickSuccess from 1 to 3', + 'emits $TickerTickSuccess from 1 to 3', build: () => TickerBloc(ticker), act: (bloc) => bloc.add(TickerStarted()), expect: () => [ @@ -42,7 +42,7 @@ void main() { ); blocTest( - 'emits TickerTickSuccess ' + 'emits $TickerTickSuccess ' 'from 1 to 3 and cancels previous subscription', build: () => TickerBloc(ticker), act: (bloc) => bloc diff --git a/examples/flutter_bloc_with_stream/test/bloc/ticker_event_test.dart b/examples/flutter_bloc_with_stream/test/bloc/ticker_event_test.dart index a8b39d4cd8f..8024b8bbe62 100644 --- a/examples/flutter_bloc_with_stream/test/bloc/ticker_event_test.dart +++ b/examples/flutter_bloc_with_stream/test/bloc/ticker_event_test.dart @@ -4,8 +4,8 @@ import 'package:flutter_bloc_with_stream/bloc/ticker_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - group('TickerEvent', () { - group('TickerStarted', () { + group(TickerEvent, () { + group(TickerStarted, () { test('supports value comparison', () { expect(TickerStarted(), equals(TickerStarted())); }); diff --git a/examples/flutter_bloc_with_stream/test/bloc/ticker_state_test.dart b/examples/flutter_bloc_with_stream/test/bloc/ticker_state_test.dart index e570075878a..ddf78f36cb7 100644 --- a/examples/flutter_bloc_with_stream/test/bloc/ticker_state_test.dart +++ b/examples/flutter_bloc_with_stream/test/bloc/ticker_state_test.dart @@ -4,14 +4,14 @@ import 'package:flutter_bloc_with_stream/bloc/ticker_bloc.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - group('TickerState', () { - group('TickerInitial', () { + group(TickerState, () { + group(TickerInitial, () { test('supports value comparison', () { expect(TickerInitial(), TickerInitial()); }); }); - group('TickerTickSuccess', () { + group(TickerTickSuccess, () { test('supports value comparison', () { expect(TickerTickSuccess(1), TickerTickSuccess(1)); expect( @@ -21,7 +21,7 @@ void main() { }); }); - group('TickerComplete', () { + group(TickerComplete, () { test('supports value comparison', () { expect(TickerComplete(), equals(TickerComplete())); }); diff --git a/examples/flutter_bloc_with_stream/test/ticker_page_test.dart b/examples/flutter_bloc_with_stream/test/ticker_page_test.dart index 3d433b75331..5804498926c 100644 --- a/examples/flutter_bloc_with_stream/test/ticker_page_test.dart +++ b/examples/flutter_bloc_with_stream/test/ticker_page_test.dart @@ -8,7 +8,7 @@ import 'package:flutter_bloc_with_stream/main.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mocktail/mocktail.dart'; -class MockTickerBloc extends MockBloc +class _MockTickerBloc extends MockBloc implements TickerBloc {} extension on WidgetTester { @@ -25,12 +25,12 @@ void main() { late TickerBloc tickerBloc; setUp(() { - tickerBloc = MockTickerBloc(); + tickerBloc = _MockTickerBloc(); }); tearDown(() => reset(tickerBloc)); - group('TickerPage', () { + group(TickerPage, () { testWidgets('renders initial state', (tester) async { when(() => tickerBloc.state).thenReturn(TickerInitial()); await tester.pumpTickerPage(tickerBloc);