Skip to content

Take Condition for async nesting expectations #1896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
28eeb2a
Take Condition for async nesting expectations
natebosch Feb 2, 2023
fe40a54
Rename asyncDescription
natebosch Feb 2, 2023
9f25f8f
Merge branch 'master' into async-take-condition-drop-which
natebosch Feb 2, 2023
8ab184b
Make `label` arguments take callbacks
natebosch Feb 3, 2023
7a0724f
Expand the doc comment for Context
natebosch Feb 3, 2023
10e6f47
Compare the non-nesting label case to a clause directly
natebosch Feb 3, 2023
bac2b3e
Mention that which can be omitted
natebosch Feb 3, 2023
8529702
dart format
natebosch Feb 3, 2023
4e4cf10
Enforce single string still in root ctor
natebosch Feb 4, 2023
00888e6
Rename _StringClause to _ExpectationClause
natebosch Feb 4, 2023
308b13d
Update docs for nest and nestAsync
natebosch Feb 4, 2023
e35574b
Consistently use double quotes to avoid escape single quote
natebosch Feb 4, 2023
915652d
Merge commit 'e35574bb' into label-callback--context-docs
natebosch Feb 4, 2023
511fa70
Merge branch 'master' into label-callback--context-docs
natebosch Feb 4, 2023
911659b
Attempt to present information in a better order
natebosch Feb 4, 2023
547abd3
More wording tweaks, add doc header on ConditionSubject
natebosch Feb 4, 2023
ef6bd7e
More wording tweaks and a paragraph on softCheck subjects
natebosch Feb 4, 2023
99f9e2f
Move the 'should not throw' phrase into a template that is used in th…
natebosch Feb 4, 2023
9400186
Merge branch 'master' into async-take-condition-drop-which
natebosch Feb 4, 2023
5a09c33
Merge branch 'master' into async-take-condition-drop-which
natebosch Feb 4, 2023
2ddbd46
Tweaks
natebosch Feb 4, 2023
d215a20
Merge branch 'label-callback--context-docs' into async-take-condition…
natebosch Feb 4, 2023
7c9fce9
Add missing generic, use {} over =>
natebosch Feb 4, 2023
3ca1aaf
Make the fields of Extracted private
natebosch Feb 4, 2023
db4fc6f
More working tweaks, export ConditionSubject
natebosch Feb 4, 2023
7890a64
Merge branch 'label-callback--context-docs' into async-take-condition…
natebosch Feb 4, 2023
b33a327
Merge branch 'master' into label-callback--context-docs
natebosch Feb 4, 2023
9d7fb07
Merge branch 'label-callback--context-docs' into async-take-condition…
natebosch Feb 4, 2023
6b38bff
Typo
natebosch Feb 4, 2023
330c3f6
Expectation extension method in Subject doc
natebosch Feb 4, 2023
4d14182
missing word
natebosch Feb 6, 2023
6a8e670
Link to example extensions, expand callback phrasing
natebosch Feb 6, 2023
afc09b3
Link the specific methods earlier
natebosch Feb 6, 2023
148ef9d
Move section on callbacks being unused to much later
natebosch Feb 6, 2023
bae48cb
Add some examples
natebosch Feb 6, 2023
e09f2ae
Revert mistaken change
natebosch Feb 6, 2023
b9b8960
Merge branch 'master' into label-callback--context-docs
natebosch Feb 6, 2023
f17581f
Merge branch 'label-callback--context-docs' into async-take-condition…
natebosch Feb 6, 2023
bfc06ed
Merge branch 'master' into async-take-condition-drop-which
natebosch Feb 6, 2023
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
9 changes: 9 additions & 0 deletions pkgs/checks/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
- `checkThat` renamed to `check`.
- `nest` and `nestAsync` take `Iterable<String> Function()` arguments for
`label` instead of `String`.
- Async expectation extensions `completes`, `throws`, `emits`, and
`emitsError` no longer return a `Future<Subject>`. Instead they take an
optional `Condition` argument which can check expectations that would
have been checked on the returned subject.
- `nestAsync` no longer returns a `Subject`, callers must pass the
followup `Condition` to the nullable argument.
- Remove the `which` extension on `Future<Subject>`.
- Add a constructor for `Condition` which takes a callback to invoke when
`apply` or `applyAsync` is called.
- Added an example.
- Include a stack trace in the failure description for unexpected errors from
Futures or Streams.
Expand Down
9 changes: 2 additions & 7 deletions pkgs/checks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ condition. The `it()` utility returns a `ConditionSubject`.
check(someList).any(it()..isGreaterThan(0));
```

Some complicated checks may be difficult to write with parenthesized awaited
expressions, or impossible to write with cascade syntax. There are `which`
utilities for both use cases which take a `Condition`.
Some complicated checks may be not be possible to write with cascade syntax.
There is a `which` utility for this use case which takes a `Condition`.

```dart
check(someString)
Expand All @@ -61,10 +60,6 @@ check(someString)
..length.which(it()
..isGreatherThan(10)
..isLessThan(100));

await check(someFuture)
.completes()
.which(it()..equals(expectedCompletion));
```

# Writing custom expectations
Expand Down
2 changes: 1 addition & 1 deletion pkgs/checks/lib/checks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

export 'src/checks.dart' show check, Subject, Skip, it;
export 'src/extensions/async.dart'
show ChainAsync, FutureChecks, StreamChecks, StreamQueueWrap;
show FutureChecks, StreamChecks, StreamQueueWrap;
export 'src/extensions/core.dart'
show BoolChecks, CoreChecks, NullabilityChecks;
export 'src/extensions/function.dart' show ThrowsCheck;
Expand Down
3 changes: 2 additions & 1 deletion pkgs/checks/lib/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

export 'src/checks.dart'
show
Subject,
CheckFailure,
Condition,
ConditionSubject,
Context,
ContextExtension,
Extracted,
FailureDetail,
Rejection,
Subject,
describe,
describeAsync,
softCheck,
Expand Down
Loading