Skip to content
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

Tighten types in test utils #2097

Merged
merged 2 commits into from
Sep 25, 2023
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
7 changes: 4 additions & 3 deletions pkgs/test/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ State? lastState;
///
/// The most recent emitted state is stored in [_lastState].
void expectStates(LiveTest liveTest, Iterable<State> statesIter) {
var states = Queue.from(statesIter);
var states = Queue.of(statesIter);
liveTest.onStateChange.listen(expectAsync1((state) {
lastState = state;
expect(state, equals(states.removeFirst()));
Expand All @@ -50,8 +50,9 @@ void expectStates(LiveTest liveTest, Iterable<State> statesIter) {

/// Asserts that errors will be emitted via [liveTest.onError] that match
/// [validators], in order.
void expectErrors(LiveTest liveTest, Iterable<Function> validatorsIter) {
var validators = Queue.from(validatorsIter);
void expectErrors(
LiveTest liveTest, Iterable<void Function(Object)> validatorsIter) {
var validators = Queue.of(validatorsIter);
liveTest.onError.listen(expectAsync1((error) {
validators.removeFirst()(error.error);
}, count: validators.length, max: validators.length));
Expand Down
2 changes: 2 additions & 0 deletions pkgs/test_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 0.6.2-wip

## 0.6.1

* Drop support for null unsafe Dart, bump SDK constraint to `3.0.0`.
Expand Down
2 changes: 1 addition & 1 deletion pkgs/test_api/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: test_api
version: 0.6.1
version: 0.6.2-wip
description: >-
The user facing API for structuring Dart tests and checking expectations.
repository: https://github.com/dart-lang/test/tree/master/pkgs/test_api
Expand Down
7 changes: 4 additions & 3 deletions pkgs/test_api/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ State? lastState;
///
/// The most recent emitted state is stored in [_lastState].
void expectStates(LiveTest liveTest, Iterable<State> statesIter) {
var states = Queue.from(statesIter);
var states = Queue.of(statesIter);
liveTest.onStateChange.listen(expectAsync1((state) {
lastState = state;
expect(state, equals(states.removeFirst()));
Expand All @@ -36,8 +36,9 @@ void expectStates(LiveTest liveTest, Iterable<State> statesIter) {

/// Asserts that errors will be emitted via [liveTest.onError] that match
/// [validators], in order.
void expectErrors(LiveTest liveTest, Iterable<Function> validatorsIter) {
var validators = Queue.from(validatorsIter);
void expectErrors(
LiveTest liveTest, Iterable<void Function(Object)> validatorsIter) {
var validators = Queue.of(validatorsIter);
liveTest.onError.listen(expectAsync1((error) {
validators.removeFirst()(error.error);
}, count: validators.length, max: validators.length));
Expand Down
Loading