-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Rename and refactor DetailsPageChangeNotifier to CharacterDetai…
…lsChangeNotifier (#14) - Remove DetailsPageChangeNotifier and its references - Implement CharacterDetailsChangeNotifier and corresponding tests - Update CharacterDetailsPage to utilize new change notifier - Create EpisodeItem widget from extracted code in CharacterDetailsPage - Update README 'Provider' test column status to 'Yes'
- Loading branch information
1 parent
bace9c9
commit 64d201a
Showing
5 changed files
with
95 additions
and
32 deletions.
There are no files selected for viewing
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
4 changes: 2 additions & 2 deletions
4
...otifier/details_page_change_notifier.dart → ...er/character_details_change_notifier.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:rickmorty/layers/domain/entity/character.dart'; | ||
|
||
class DetailsPageChangeNotifier extends ChangeNotifier { | ||
DetailsPageChangeNotifier({required this.character}); | ||
class CharacterDetailsChangeNotifier extends ChangeNotifier { | ||
CharacterDetailsChangeNotifier({required this.character}); | ||
|
||
final Character character; | ||
} |
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
16 changes: 16 additions & 0 deletions
16
...n/using_provider/details_page/change_notifier/character_details_change_notifier_test.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:rickmorty/layers/presentation/using_provider/details_page/change_notifier/character_details_change_notifier.dart'; | ||
|
||
import '../../../../../../fixtures/fixtures.dart'; | ||
|
||
void main() { | ||
group('CharacterDetailsChangeNotifier', () { | ||
test('initial state is correct', () { | ||
final c = characterList1.first; | ||
|
||
final notifier = CharacterDetailsChangeNotifier(character: c); | ||
|
||
expect(notifier.character, c); | ||
}); | ||
}); | ||
} |
34 changes: 34 additions & 0 deletions
34
...lib/layers/presentation/using_provider/details_page/view/character_details_page_test.dart
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:provider/provider.dart'; | ||
import 'package:rickmorty/layers/presentation/using_provider/details_page/change_notifier/character_details_change_notifier.dart'; | ||
import 'package:rickmorty/layers/presentation/using_provider/details_page/view/character_details_page.dart'; | ||
|
||
import '../../../../../../fixtures/fixtures.dart'; | ||
|
||
void main() { | ||
testWidgets('CharacterDetailsPage should render correctly', (WidgetTester tester) async { | ||
final character = characterList1.first; | ||
|
||
// Build our app and trigger a frame. | ||
await tester.pumpWidget( | ||
MaterialApp( | ||
home: ChangeNotifierProvider( | ||
create: (_) => CharacterDetailsChangeNotifier(character: character), | ||
child: const CharacterDetailsPage(), | ||
), | ||
), | ||
); | ||
|
||
// Find items on the page | ||
expect(find.text('Details'), findsOneWidget); | ||
expect(find.text(character.name!), findsOneWidget); | ||
expect(find.text('Origin: ${character.origin!.name}'), findsOneWidget); | ||
expect(find.text('Species: ${character.species}'), findsOneWidget); | ||
expect(find.text('Type: ${character.type}'), findsOneWidget); | ||
expect(find.text('Gender: ${character.gender}'), findsOneWidget); | ||
expect(find.text('Status: ${character.isAlive ? 'ALIVE!' : 'DEAD!'}'), findsOneWidget); | ||
expect(find.text('Last location: ${character.location!.name}'), findsOneWidget); | ||
expectLater(find.byType(EpisodeItem), findsNWidgets(character.episode!.length)); | ||
}); | ||
} |