[testing_app] added basic placeholder for favorites list (#581)

pull/596/head
Tushar Ojha 4 years ago committed by GitHub
parent dcbbc31119
commit 84d0251e2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,11 +16,16 @@ class FavoritesPage extends StatelessWidget {
title: Text('Favorites'),
),
body: Consumer<Favorites>(
builder: (context, value, child) => ListView.builder(
itemCount: value.items.length,
padding: const EdgeInsets.symmetric(vertical: 16),
itemBuilder: (context, index) => FavoriteItemTile(value.items[index]),
),
builder: (context, value, child) => value.items.isNotEmpty
? ListView.builder(
itemCount: value.items.length,
padding: const EdgeInsets.symmetric(vertical: 16),
itemBuilder: (context, index) =>
FavoriteItemTile(value.items[index]),
)
: Center(
child: Text('No favorites added.'),
),
),
);
}

@ -28,6 +28,14 @@ void addItems() {
void main() {
group('Favorites Page Widget Tests', () {
testWidgets('Test if Placeholder shows in case of empty list',
(tester) async {
await tester.pumpWidget(createFavoritesScreen());
// Verify if the placeholder text shows up.
expect(find.text('No favorites added.'), findsOneWidget);
});
testWidgets('Test if ListView shows up', (tester) async {
await tester.pumpWidget(createFavoritesScreen());

@ -11,7 +11,6 @@ void main() {
var favorites = Favorites();
test('A new item should be added', () {
// Generate a random number.
var number = 35;
// Add the number to the list.
@ -22,7 +21,6 @@ void main() {
});
test('An item should be removed', () {
// Generate a random number.
var number = 45;
// Add the number to the list.

Loading…
Cancel
Save