diff --git a/README.md b/README.md index abb565d2..ec7bc106 100644 --- a/README.md +++ b/README.md @@ -460,7 +460,7 @@ void main() { spot().withText('c').doesNotExist(); spot().withText('c').overrideWidgetPresence(WidgetPresence.offstage).existsOnce(); - spotOffstage().spot().atMost(3); + spotOffstage().spot().existsAtMostNTimes(3); spotOffstage().spotText('c').existsOnce(); spotOffstage().overrideWidgetPresence(WidgetPresence.onstage).spotText('c').doesNotExist(); diff --git a/lib/src/spot/selectors.dart b/lib/src/spot/selectors.dart index 798df168..e8969dcf 100644 --- a/lib/src/spot/selectors.dart +++ b/lib/src/spot/selectors.dart @@ -721,16 +721,19 @@ extension ReadSingleSnapshot on WidgetSelector { /// selection of widgets. extension QuantitySelectors on WidgetSelector { /// Sets the selector to match exactly [n] widgets. + @useResult WidgetSelector amount(int n) { return self.overrideQuantityConstraint(QuantityConstraint.exactly(n)); } /// Sets the selector to match at least [n] widgets. + @useResult WidgetSelector atLeast(int n) { return self.overrideQuantityConstraint(QuantityConstraint.atLeast(n)); } /// Sets the selector to match at most [n] widgets. + @useResult WidgetSelector atMost(int n) { return self.overrideQuantityConstraint(QuantityConstraint.atMost(n)); } @@ -739,6 +742,7 @@ extension QuantitySelectors on WidgetSelector { /// /// This method allows for more flexible control over the number of widgets /// the selector should match. + @useResult WidgetSelector overrideQuantityConstraint(QuantityConstraint constraint) { return self.copyWith(quantityConstraint: constraint); } diff --git a/test/selectors/filter_test.dart b/test/selectors/filter_test.dart index e7d18f07..ad3a9022 100644 --- a/test/selectors/filter_test.dart +++ b/test/selectors/filter_test.dart @@ -142,7 +142,7 @@ void main() { ), ); - spot().atMost(2); + spot().existsAtMostNTimes(2); spotText('c').doesNotExist(); }); @@ -160,11 +160,11 @@ void main() { ), ); - spot().atMost(2); + spot().existsAtMostNTimes(2); spotText('a').existsExactlyNTimes(1); spotText('c').doesNotExist(); - spotOffstage().spot().atMost(1); + spotOffstage().spot().existsAtMostNTimes(1); spotOffstage().spotText('a').doesNotExist(); spotOffstage().spotText('c').existsOnce(); }); @@ -184,7 +184,7 @@ void main() { ), ); - spotOffstage().spot().atMost(3); + spotOffstage().spot().existsAtMostNTimes(3); spotOffstage().spotText('a').doesNotExist(); spotOffstage().spotText('c').existsOnce(); spotOffstage() @@ -253,7 +253,7 @@ void main() { ), ); - spotAllWidgets().spot().atMost(3); + spotAllWidgets().spot().existsAtMostNTimes(3); spotAllWidgets().spotText('a').existsOnce(); spotAllWidgets().spotText('c').existsOnce(); spotAllWidgets()