Skip to content

Commit

Permalink
Prepare release 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
passsy committed Dec 25, 2023
1 parent 5fa201c commit c35db85
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
67 changes: 67 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,72 @@
# Changelog

## 0.7.0

- New prop API with `hasWidgetProp()` makes it easy to filter and assert properties of Widgets.
This replaces the old `hasProp()` method which was based on way to complicated package:checks context.
```dart
// Old ⛈️
spotSingle<Checkbox>().existsOnce().hasProp(
selector: (e) => e.context.nest(
() => ['Checkbox', 'value'],
(e) => Extracted.value((e.widget as Checkbox).value),
),
match: (it) => it.equals(true),
);
```
```dart
// New ✨
spotSingle<Checkbox>().existsOnce().hasWidgetProp(
prop: widgetProp('value', (widget) => widget.value),
match: (value) => value.isTrue(),
);
```

The prop API is also available for `Element` and `RenderObject`.
<summary>
<details>

```
├── Interface "NamedWidgetProp" added
├── Interface "NamedElementProp" added
├── Interface "NamedRenderObjectProp" added
├── Function "widgetProp" added
├── Function "elementProp" added
├── Function "renderObjectProp" added
├─┬ Class SelectorQueries
│ ├── Method "whereWidgetProp" added
│ ├── Method "whereElementProp" added
│ └── Method "whereRenderObjectProp" added
└─┬ Class WidgetMatcherExtensions
├── Method "getWidgetProp" added
├── Method "hasWidgetProp" added
├── Method "getElementProp" added
├── Method "hasElementProp" added
├── Method "getRenderObjectProp" added
└── Method "hasRenderObjectProp" added
```
</details>
</summary>

- Never miss asserting your `WidgetSelector`.
All methods returning a `WidgetSelector` are now annotated with `@useResult`.
This will cause a lint warning when you only define a `WidgetSelector` without asserting it.
```dart
spot<FloatingActionButton>().withChild(spotIcon(Icons.add)); // warning, no assertion
final plusFab = spot<FloatingActionButton>().withChild(spotIcon(Icons.add)); // ok, assigned
spot<FloatingActionButton>().withChild(spotIcon(Icons.add)).existsOnce(); // ok, asserted
```

- It is now easy to directly access the Widget of a `SingleWidgetSelector` with `snapshotWidget()`.
It also works for the associated `Element` and `RenderObject`. Use `snapshotElement()` and `snapshotRenderObject()`.

```diff
-final checkbox = spotSingle<Checkbox>().snapshot().widget;
+final checkbox = spotSingle<Checkbox>().snapshotWidget();
print(checkbox.checkColor);
```

## 0.6.0
- Add matchers `.existsAtMostOnce()` and `.existsAtMostNTimes(x)` #19
- Add selector `.withParent(parent)`/`.withParents([...])` #21
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: spot
description: Chainable finders and better assertions for powerful widget tests.
version: 0.6.0
version: 0.7.0
repository: https://github.com/passsy/spot
issue_tracker: https://github.com/passsy/spot/issues

Expand Down

0 comments on commit c35db85

Please sign in to comment.