You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
samples/add_to_app/flutter_module_books/test/widget_test.dart

44 lines
1.2 KiB

// Copyright 2020 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_module_books/api.dart';
import 'package:flutter_module_books/main.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
void main() {
testWidgets('Pressing clear calls the cancel API',
(WidgetTester tester) async {
MockHostBookApi mockHostApi = MockHostBookApi();
await tester.pumpWidget(
MaterialApp(
home: BookDetail(hostApi: mockHostApi),
),
);
await tester.tap(find.byIcon(Icons.clear));
verify(mockHostApi.cancel());
});
testWidgets('Pressing done calls the finish editing API',
(WidgetTester tester) async {
MockHostBookApi mockHostApi = MockHostBookApi();
await tester.pumpWidget(
MaterialApp(
home: BookDetail(hostApi: mockHostApi),
),
);
await tester.tap(find.byIcon(Icons.check));
verify(mockHostApi.finishEditingBook(any));
});
}
class MockHostBookApi extends Mock implements HostBookApi {}