mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 14:58:34 +00:00
Add provider_shopper (#87)
This is the code for the sample at https://flutter.dev/docs/development/data-and-backend/state-mgmt/simple.
This commit is contained in:
29
provider_shopper/test/widget_test.dart
Normal file
29
provider_shopper/test/widget_test.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright 2019 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:provider_shopper/main.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('smoke test', (tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(MyApp());
|
||||
|
||||
// Check that shopping cart is empty at start.
|
||||
await tester.tap(find.byIcon(Icons.shopping_cart));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('\$0'), findsOneWidget);
|
||||
|
||||
// Buy an item.
|
||||
await tester.pageBack();
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('ADD').first);
|
||||
|
||||
// Check that the shopping cart is not empty anymore.
|
||||
await tester.tap(find.byIcon(Icons.shopping_cart));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('\$0'), findsNothing);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user