Skip to content

Commit

Permalink
feature: testing tests from catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
efraespada committed Oct 4, 2024
1 parent 0682c18 commit afeb849
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 4 deletions.
48 changes: 48 additions & 0 deletions example/lib/widgets/utils/bottom/catalog/test/fab_widget.test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/// AUTOGENERATED FILE.
///
/// Use this file for testing the widget FabWidgetPreview
///
import 'package:catalog/catalog.dart';

import '../../fab_widget.dart';
import '../dummy/fab_widget.dummy.dart';

class FabWidgetTest {
void main() {
group(
'FabWidget - Tests',
() {
testWidgets(
'Lorem text not found',
(tester) async {
final dummy = FabWidgetDummy().dummies.first;

final widget = FabWidget(
incrementCounter: dummy.parameters['incrementCounter'],
);

await tester.test(widget);

expect(find.text('lorem ipsu'), findsNothing);
},
);

testWidgets(
'Other lorem text not found',
(tester) async {
final dummy = FabWidgetDummy().dummies.first;

final widget = FabWidget(
incrementCounter: dummy.parameters['incrementCounter'],
);

await tester.test(widget);

expect(find.text('lorem ipsu'), findsNothing);
},
);
},
);
}
}
5 changes: 5 additions & 0 deletions example/test/catalog_widget_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:example/widgets/utils/bottom/catalog/test/fab_widget.test.dart';

void main() {
FabWidgetTest().main();
}
3 changes: 1 addition & 2 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:example/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:example/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
Expand Down
2 changes: 2 additions & 0 deletions lib/catalog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ export 'package:catalog/src/builders/screenshots/types/apple/i_pad_pro_3gen.dart
export 'package:catalog/src/builders/screenshots/types/apple/i_phone_55.dart';
export 'package:catalog/src/builders/screenshots/types/apple/i_phone_65.dart';
export 'package:catalog/src/builders/screenshots/types/apple/macos.dart';
export 'package:catalog/src/extensions/widget_test_ext.dart';
export 'package:catalog/src/catalog_runner.dart';
export 'package:catalog/src/builders/catalog/component_node.dart';
export 'package:catalog/src/utils/constants.dart';
export 'package:catalog/src/embed/flutter_fanacy_tree_view/flutter_fancy_tree_view.dart';
export 'package:catalog/src/extensions/locale_ext.dart';
export 'package:device_frame/device_frame.dart';
export 'package:go_router/go_router.dart';
export 'package:flutter_test/flutter_test.dart';

class Catalog {
static Catalog? _instance;
Expand Down
17 changes: 17 additions & 0 deletions lib/src/extensions/widget_test_ext.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:stringcare/stringcare.dart';

extension WidgetTestExt on WidgetTester {
Future<void> test(Widget widget) async {
await pumpWidget(
MaterialApp(
navigatorKey: Stringcare().navigatorKey,
supportedLocales: Stringcare().locales,
localizationsDelegates: Stringcare().delegates,
home: widget,
),
);
await pumpAndSettle();
}
}
5 changes: 3 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ dependencies:
http: ^1.2.2 # android ios linux macos web windows
image: ^4.2.0 # android ios linux macos web windows
shelf: ^1.4.1 # android ios linux macos web windows
stringcare: ^0.1.7 # android ios linux macos web windows
vector_graphics: ^1.1.11+1 # android ios linux macos web windows
yaml: ^3.1.2 # android ios linux macos web windows
yaml_writer: ^2.0.0 # android ios linux macos web windows

dev_dependencies:
flutter_test:
sdk: flutter

dev_dependencies:
flutter_lints: ^5.0.0

0 comments on commit afeb849

Please sign in to comment.