Skip to content

Commit 375193d

Browse files
feat: 0.2.0 (#17)
1 parent 556a761 commit 375193d

15 files changed

+674
-183
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# 0.2.0-dev.3
2+
3+
- feat: add mock call for `canPop` (thanks [@allisonryan0002](https://github.com/allisonryan0002)!)
4+
5+
# 0.2.0-dev.2
6+
7+
- feat: add mock call for `maybePop` (thanks [@korzonkiee](https://github.com/korzonkiee)!)
8+
9+
# 0.2.0-dev.1
10+
11+
- feat: add `whereSettings`, `whereName`, `whereArguments`, `whereMaintainState` and `whereFullscreenDialog` matcher arguments to `isRoute` matcher
12+
- **DEPRECATE**: fix: `named` argument on `isRoute` deprecated in favor of `whereName`
13+
114
# 0.1.1
215

316
- refactor: reorder mock navigator provider parameters ([#14](https://github.com/VeryGoodOpenSource/mockingjay/pull/14), thanks [@JigneshPatel23](https://github.com/JigneshPatel23))

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void main() {
9090
await tester.tap(find.byType(TextButton));
9191
9292
verify(
93-
() => navigator.push(any(that: isRoute<void>(named: '/settings'))),
93+
() => navigator.push(any(that: isRoute<void>(whereName: equals('/settings')))),
9494
).called(1);
9595
});
9696
}

analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include: package:very_good_analysis/analysis_options.2.3.0.yaml
1+
include: package:very_good_analysis/analysis_options.2.4.0.yaml

example/analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:very_good_analysis/analysis_options.2.3.0.yaml
1+
include: package:very_good_analysis/analysis_options.2.4.0.yaml
22
linter:
33
rules:
44
public_member_api_docs: false

example/lib/ui/home_screen.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import 'dart:io';
2-
31
import 'package:example/ui/ui.dart';
42
import 'package:flutter/material.dart';
3+
import 'package:universal_io/io.dart';
54

65
class HomeScreen extends StatefulWidget {
76
const HomeScreen({Key? key}) : super(key: key);
87

98
@override
10-
_HomeScreenState createState() => _HomeScreenState();
9+
State<HomeScreen> createState() => _HomeScreenState();
1110
}
1211

1312
class _HomeScreenState extends State<HomeScreen> {

example/lib/ui/pincode_screen.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import 'dart:io';
2-
31
import 'package:flutter/material.dart';
42
import 'package:flutter/services.dart';
3+
import 'package:universal_io/io.dart';
54

65
class PincodeScreen extends StatefulWidget {
76
const PincodeScreen({Key? key}) : super(key: key);
@@ -17,7 +16,7 @@ class PincodeScreen extends StatefulWidget {
1716
}
1817

1918
@override
20-
_PincodeScreenState createState() => _PincodeScreenState();
19+
State<PincodeScreen> createState() => _PincodeScreenState();
2120
}
2221

2322
class _PincodeScreenState extends State<PincodeScreen> {

example/pubspec.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,21 @@ environment:
88
flutter: ">=1.17.0"
99

1010
dependencies:
11-
bloc: ^7.0.0
11+
bloc: ^8.0.0
1212
equatable: ^2.0.3
1313
flutter:
1414
sdk: flutter
15-
flutter_bloc: ^7.1.0
15+
flutter_bloc: ^8.0.0
16+
universal_io: ^2.0.4
1617

1718
dev_dependencies:
18-
bloc_test: ^8.1.0
19+
bloc_test: ^9.0.0
1920
flutter_test:
2021
sdk: flutter
2122
mockingjay:
2223
path: ../
23-
mocktail: ^0.1.4
24-
very_good_analysis: ^2.3.0
24+
mocktail: ^0.2.0
25+
very_good_analysis: ^2.4.0
2526

2627
flutter:
2728
uses-material-design: true

example/test/ui/home_screen_test.dart

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,17 @@ void main() {
5151

5252
verify(
5353
() => navigator.push(
54-
any(that: isRoute<String?>(named: '/pincode_screen')),
54+
any(that: isRoute<String?>(whereName: equals('/pincode_screen'))),
5555
),
5656
).called(1);
5757
});
5858

5959
testWidgets('displays snackbar with selected pincode', (tester) async {
60-
when(() => navigator.push(
61-
any(that: isRoute<String?>(named: '/pincode_screen')),
62-
)).thenAnswer((_) async => '123456');
60+
when(
61+
() => navigator.push(
62+
any(that: isRoute<String?>(whereName: equals('/pincode_screen'))),
63+
),
64+
).thenAnswer((_) async => '123456');
6365

6466
await tester.pumpTest(
6567
builder: (context) {
@@ -82,9 +84,15 @@ void main() {
8284
testWidgets(
8385
'displays snackbar when no pincode was submitted',
8486
(tester) async {
85-
when(() => navigator.push(
86-
any(that: isRoute<String?>(named: '/pincode_screen')),
87-
)).thenAnswer((_) async => null);
87+
when(
88+
() => navigator.push(
89+
any(
90+
that: isRoute<String?>(
91+
whereName: equals('/pincode_screen'),
92+
),
93+
),
94+
),
95+
).thenAnswer((_) async => null);
8896

8997
await tester.pumpTest(
9098
builder: (context) {

lib/src/matcher_extensions.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import 'package:matcher/matcher.dart';
2+
3+
/// Extensions on [Matcher] for convenience.
4+
extension MatcherExtensions on Matcher {
5+
/// Returns the description of this matcher as a string.
6+
String describeAsString() {
7+
return describe(StringDescription()).toString();
8+
}
9+
10+
/// Returns the mismatch description of this matcher as a string.
11+
// ignore: avoid_positional_boolean_parameters
12+
String describeMismatchAsString(dynamic item, Map matchState, bool verbose) {
13+
final description = describeMismatch(
14+
item,
15+
StringDescription(),
16+
matchState,
17+
verbose,
18+
);
19+
20+
if (description.toString().isEmpty) {
21+
return 'is $item instead of ${describeAsString()}';
22+
} else {
23+
return description.toString();
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)