Skip to content

Commit 941d559

Browse files
committed
test: implement widget test for success motion toast type
1 parent ac2323b commit 941d559

3 files changed

Lines changed: 105 additions & 12 deletions

File tree

example/test/widget_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import 'package:flutter_test/flutter_test.dart';
33
void main() {
44
test('Counter increments smoke test', () async {
55
// This is an example test that checks if the counter increments correctly.
6-
// TODO - Implement the actual widget test.
76
expect(1, 1);
87
});
98
}

pubspec.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ packages:
55
dependency: transitive
66
description:
77
name: async
8-
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
8+
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
99
url: "https://pub.dev"
1010
source: hosted
11-
version: "2.13.0"
11+
version: "2.12.0"
1212
boolean_selector:
1313
dependency: transitive
1414
description:
@@ -45,10 +45,10 @@ packages:
4545
dependency: transitive
4646
description:
4747
name: fake_async
48-
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
48+
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
4949
url: "https://pub.dev"
5050
source: hosted
51-
version: "1.3.3"
51+
version: "1.3.2"
5252
flutter:
5353
dependency: "direct main"
5454
description: flutter
@@ -71,10 +71,10 @@ packages:
7171
dependency: transitive
7272
description:
7373
name: leak_tracker
74-
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
74+
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
7575
url: "https://pub.dev"
7676
source: hosted
77-
version: "10.0.9"
77+
version: "10.0.8"
7878
leak_tracker_flutter_testing:
7979
dependency: transitive
8080
description:
@@ -196,10 +196,10 @@ packages:
196196
dependency: transitive
197197
description:
198198
name: vm_service
199-
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
199+
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
200200
url: "https://pub.dev"
201201
source: hosted
202-
version: "15.0.0"
202+
version: "14.3.1"
203203
sdks:
204204
dart: ">=3.7.0-0 <4.0.0"
205205
flutter: ">=3.18.0-18.0.pre.54"

test/widget_test.dart

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,105 @@
44
// utility that Flutter provides. For example, you can send tap and scroll
55
// gestures. You can also use WidgetTester to find child widgets in the widget
66
// tree, read text, and verify that the values of widget properties are correct.
7+
import 'package:flutter/material.dart';
78
import 'package:flutter_test/flutter_test.dart';
9+
import 'package:motion_toast/motion_toast.dart';
810

9-
// TODO: write unit tests for motion toast widget
1011
void main() {
11-
test('Counter increments smoke test', () async {
12-
expect(true, isTrue);
12+
group('Success motion toast testing...', () {
13+
testWidgets(
14+
'Basic motion toast widget test',
15+
(tester) async {
16+
var basicMotionToastWidget = MotionToast.success(
17+
description: const Text(
18+
'Elegant notification description',
19+
),
20+
);
21+
await tester.pumpWidget(
22+
MaterialApp(
23+
home: Scaffold(
24+
body: Center(
25+
child: basicMotionToastWidget,
26+
),
27+
),
28+
),
29+
);
30+
expect(
31+
find.byType(Text),
32+
findsOneWidget,
33+
);
34+
expect(
35+
find.byType(Icon),
36+
findsOneWidget,
37+
);
38+
},
39+
);
40+
41+
testWidgets(
42+
'Motion toast with title widget test',
43+
(tester) async {
44+
var basicMotionToastWidget = MotionToast.success(
45+
description: const Text(
46+
'Elegant notification description',
47+
),
48+
title: const Text(
49+
'Elegant notification title',
50+
),
51+
);
52+
await tester.pumpWidget(
53+
MaterialApp(
54+
home: Scaffold(
55+
body: Center(
56+
child: basicMotionToastWidget,
57+
),
58+
),
59+
),
60+
);
61+
expect(
62+
find.byType(Text),
63+
findsAtLeast(2),
64+
);
65+
expect(
66+
find.byType(Icon),
67+
findsOneWidget,
68+
);
69+
},
70+
);
71+
72+
testWidgets(
73+
'Motion toast with title and toast duration widget test',
74+
(tester) async {
75+
var basicMotionToastWidget = MotionToast.success(
76+
description: const Text(
77+
'Elegant notification description',
78+
),
79+
title: const Text(
80+
'Elegant notification title',
81+
),
82+
toastDuration: const Duration(seconds: 1),
83+
);
84+
await tester.pumpWidget(
85+
MaterialApp(
86+
home: Scaffold(
87+
body: Center(
88+
child: basicMotionToastWidget,
89+
),
90+
),
91+
),
92+
);
93+
expect(
94+
find.byType(Text),
95+
findsAtLeast(2),
96+
);
97+
expect(
98+
find.byType(Icon),
99+
findsOneWidget,
100+
);
101+
expect(
102+
find.byType(MotionToast),
103+
findsOneWidget,
104+
);
105+
},
106+
);
13107
});
14108
}

0 commit comments

Comments
 (0)