Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
build:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v1
with:
runs_on: macos-latest
flutter_channel: stable
flutter_version: "3.32.0"
flutter_version: "3.35.x"
working_directory: example
runs_on: macos-latest
9 changes: 1 addition & 8 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,10 @@ jobs:
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/semantic_pull_request.yml@v1

build:
strategy:
matrix:
flutter-version:
# The version of Flutter to use should use the minimum Dart SDK version supported by the package,
# refer to https://docs.flutter.dev/development/tools/sdk/releases.
- "3.32.0"
- "3.x"
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/flutter_package.yml@v1
with:
flutter_channel: stable
flutter_version: ${{ matrix.flutter-version }}
flutter_version: "3.35.x"
package_get_excludes: example

spell-check:
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 0.0.1
homepage: https://github.com/VeryGoodOpenSource/mockingjay

environment:
sdk: ^3.8.0
flutter: ^3.32.0
sdk: ^3.9.0
flutter: ^3.35.0

dependencies:
bloc: ^9.0.0
Expand All @@ -22,7 +22,7 @@ dev_dependencies:
mockingjay:
path: ../
mocktail: ^1.0.4
very_good_analysis: ^9.0.0
very_good_analysis: ^10.0.0

flutter:
uses-material-design: true
1 change: 0 additions & 1 deletion lib/src/matcher_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ extension MatcherExtensions on Matcher {
}

/// Returns the mismatch description of this matcher as a string.
// ignore: avoid_positional_boolean_parameters
String describeMismatchAsString(
dynamic item,
Map<dynamic, dynamic> matchState, {
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 2.0.0
homepage: https://github.com/VeryGoodOpenSource/mockingjay

environment:
sdk: ^3.8.0
flutter: ">=3.32.0"
sdk: ^3.9.0
flutter: ^3.35.0

dependencies:
flutter:
Expand All @@ -17,4 +17,4 @@ dependencies:
test: ^1.25.7

dev_dependencies:
very_good_analysis: ^9.0.0
very_good_analysis: ^10.0.0
163 changes: 86 additions & 77 deletions test/src/matchers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@ void main() {
expect(createRoute<String>(name: '/test'), isRoute());
});

test('does not match anything that is not a route', () {
expectToFail(
test('does not match anything that is not a route', () async {
await expectToFail(
1,
isRoute(),
withMessage: 'is not a route but an instance of `int`',
);
expectToFail(
await expectToFail(
'a',
isRoute(),
withMessage: 'is not a route but an instance of `String`',
);
expectToFail(
await expectToFail(
null,
isRoute(),
withMessage: 'is not a route but an instance of `Null`',
);
expectToFail(
await expectToFail(
const SizedBox(),
isRoute(),
withMessage: 'is not a route but an instance of `SizedBox`',
Expand All @@ -96,23 +96,26 @@ void main() {
expect(createRoute<String>(name: '/test'), isRoute<String>());
});

test('does not match anything that is not a route of that type', () {
expectToFail(
createRoute<dynamic>(),
isRoute<String>(),
withMessage: 'is a route of type `dynamic` instead of `String`',
);
expectToFail(
createRoute<dynamic>(name: '/test'),
isRoute<String>(),
withMessage: 'is a route of type `dynamic` instead of `String`',
);
expectToFail(
1,
isRoute<String>(),
withMessage: 'is not a route but an instance of `int`',
);
});
test(
'does not match anything that is not a route of that type',
() async {
await expectToFail(
createRoute<dynamic>(),
isRoute<String>(),
withMessage: 'is a route of type `dynamic` instead of `String`',
);
await expectToFail(
createRoute<dynamic>(name: '/test'),
isRoute<String>(),
withMessage: 'is a route of type `dynamic` instead of `String`',
);
await expectToFail(
1,
isRoute<String>(),
withMessage: 'is not a route but an instance of `int`',
);
},
);
});

group('with whereSettings argument', () {
Expand All @@ -134,14 +137,14 @@ void main() {
});

test('does not match anything that is not a route '
'with matching settings', () {
expectToFail(
'with matching settings', () async {
await expectToFail(
createRoute<dynamic>(name: '/test'),
isRoute(whereSettings: equalsSettingsOf(createRoute<String>())),
withMessage:
"is a route where `settings` has `name` with value '/test'",
);
expectToFail(
await expectToFail(
createRoute<dynamic>(name: '/other_name'),
isRoute(
whereSettings: equalsSettingsOf(
Expand All @@ -155,7 +158,7 @@ is a route where `settings` has `name` with value '/other_name' which is differe
^
Differ at offset 1''',
);
expectToFail(
await expectToFail(
1,
isRoute(whereSettings: equalsSettingsOf(createRoute<dynamic>())),
withMessage: 'is not a route but an instance of `int`',
Expand All @@ -175,29 +178,32 @@ is a route where `settings` has `name` with value '/other_name' which is differe
);
});

test('does not match anything that is not a route with that name', () {
expectToFail(
createRoute<dynamic>(),
isRoute(whereName: equals('/test')),
withMessage:
"is a route where the route's `name` is empty instead of '/test'",
);
expectToFail(
createRoute<dynamic>(name: '/other_name'),
isRoute(whereName: equals('/test')),
withMessage: '''
test(
'does not match anything that is not a route with that name',
() async {
await expectToFail(
createRoute<dynamic>(),
isRoute(whereName: equals('/test')),
withMessage:
"is a route where the route's `name` is empty instead of '/test'",
);
await expectToFail(
createRoute<dynamic>(name: '/other_name'),
isRoute(whereName: equals('/test')),
withMessage: '''
is a route where the route's `name` is different.
Expected: /test
Actual: /other_name ...
^
Differ at offset 1''',
);
expectToFail(
1,
isRoute(whereName: equals('/test')),
withMessage: 'is not a route but an instance of `int`',
);
});
);
await expectToFail(
1,
isRoute(whereName: equals('/test')),
withMessage: 'is not a route but an instance of `int`',
);
},
);
});

group('with whereArguments argument', () {
Expand All @@ -214,22 +220,22 @@ is a route where the route's `name` is different.

test(
'does not match anything that is not a route with same arguments',
() {
expectToFail(
() async {
await expectToFail(
createRoute<dynamic>(arguments: {'a': 1}),
isRoute(whereArguments: equals({'a': 2})),
withMessage:
"is a route where the route's `arguments` "
"at location ['a'] is <1> instead of <2>",
);
expectToFail(
await expectToFail(
createRoute<dynamic>(arguments: {'a': 1}),
isRoute(whereArguments: equals({'b': 1})),
withMessage:
"is a route where the route's `arguments` "
"is missing map key 'b'",
);
expectToFail(
await expectToFail(
1,
isRoute(whereArguments: equals({'a': 1})),
withMessage: 'is not a route but an instance of `int`',
Expand All @@ -244,23 +250,23 @@ is a route where the route's `name` is different.
});

test('does not match anything that is not a route with matching '
'maintainState argument', () {
expectToFail(
'maintainState argument', () async {
await expectToFail(
createRoute<dynamic>(),
isRoute(whereMaintainState: isFalse),
withMessage:
'is a route where `maintainState` '
'is true instead of false',
);
expectToFail(
await expectToFail(
NonModalRoute(),
isRoute(whereMaintainState: isTrue),
withMessage:
'is a route where `maintainState` '
'is not a property on `NonModalRoute` and can only be used '
'with `ModalRoute`s',
);
expectToFail(
await expectToFail(
1,
isRoute(whereMaintainState: isTrue),
withMessage: 'is not a route but an instance of `int`',
Expand All @@ -276,33 +282,36 @@ is a route where the route's `name` is different.
);
});

test('does not match anything that is not a route with matching '
'fullscreenDialog argument', () {
expectToFail(
createRoute<dynamic>(fullscreenDialog: true),
isRoute(whereFullscreenDialog: isFalse),
withMessage:
'is a route where `fullscreenDialog` '
'is true instead of false',
);
expectToFail(
NonModalRoute(),
isRoute(whereFullscreenDialog: isFalse),
withMessage:
'is a route where `fullscreenDialog` '
'is not a property on `NonModalRoute` and can only be used '
'with `PageRoute`s',
);
expectToFail(
1,
isRoute(whereFullscreenDialog: isTrue),
withMessage: 'is not a route but an instance of `int`',
);
});
test(
'does not match anything that is not a route with matching '
'fullscreenDialog argument',
() async {
await expectToFail(
createRoute<dynamic>(fullscreenDialog: true),
isRoute(whereFullscreenDialog: isFalse),
withMessage:
'is a route where `fullscreenDialog` '
'is true instead of false',
);
await expectToFail(
NonModalRoute(),
isRoute(whereFullscreenDialog: isFalse),
withMessage:
'is a route where `fullscreenDialog` '
'is not a property on `NonModalRoute` and can only be used '
'with `PageRoute`s',
);
await expectToFail(
1,
isRoute(whereFullscreenDialog: isTrue),
withMessage: 'is not a route but an instance of `int`',
);
},
);
});

test('returns all relevant mismatches in one log', () {
expectToFail(
test('returns all relevant mismatches in one log', () async {
await expectToFail(
createRoute<dynamic>(
name: '/other_name',
arguments: {'b': 1},
Expand Down