Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
squatto committed May 31, 2023
1 parent fb4bd97 commit a410a19
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ Using the following response body:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>pest-plugin-selectors test view</title>
<title>quadraecom/pest-plugin-selectors test view</title>
</head>
<body>

Expand All @@ -29,7 +30,7 @@ Using the following response body:
<li>List item 2</li>
<li>List item 3</li>
<li>List item 4</li>
<li>List item 5</li>
<li data-foo="bar">List item 5</li>
</ul>

<div class="single">
Expand Down Expand Up @@ -58,6 +59,8 @@ Using the following response body:
The following tests will all pass:

```php
use PHPUnit\Framework\AssertionFailedError;

it('gets elements matching a selector', function () {
/** @var DOMNodeList $elements */
$elements = $this->get('/')
Expand Down Expand Up @@ -115,27 +118,36 @@ it("asserts that all of a selector's matches do not equal a value")
->get('/')
->assertSelectorsAllNotEqual('main div.multiple-same .item', 'not the value');

it("asserts that a selector match's attribute equals a value")
it("asserts that an attribute exists on any of a selector's matches")
->get('/')
->assertSelectorAttributeExists('main ul li', 'data-foo');

it("asserts that an attribute does not exist on any of a selector's matches")
->get('/')
->assertSelectorAttributeNotExists('main ul li', 'data-does-not-exist');

it("asserts that an attribute equals a value on any of a selector's matches")
->get('/')
->assertSelectorAttributeEquals('footer', 'data-foo', 'bar');
->assertSelectorAttributeEquals('main ul li', 'data-foo', 'bar');

it("asserts that a selector match's attribute does not equal a value")
it("asserts that an attribute does not equal a value on any of a selector's matches")
->get('/')
->assertSelectorAttributeNotEquals('footer', 'data-foo', 'not the value');
->assertSelectorAttributeNotEquals('main ul li', 'data-foo', 'not the value');
```

---

> If you want to start testing your application with Pest, visit the main **[Pest Repository](https://github.com/pestphp/pest)**.
> If you want to start testing your application with Pest, visit the main
> **[Pest Repository](https://github.com/pestphp/pest)**.
### Package Author

This package was created and is maintained by [Quadra Ecommerce](https://github.com/QuadraEcommerce).
This package was created and is maintained by [Quadra, Inc](https://github.com/QuadraEcommerce).

- Website: **[QuadraEcom.com](https://quadraecom.com)**
- Website: **[GoQuadra.com](https://goquadra.com)**
- GitHub: **[QuadraEcommerce](https://github.com/QuadraEcommerce)**

[The original test assertions](src/Plugin.php) were based on code originally written
[The test assertions](src/Plugin.php) were inspired by code written
by [Liam Hammett (@ImLiam)](https://github.com/ImLiam) that can be found in
[this post on his blog](https://liamhammett.com/laravel-testing-css-selector-assertion-macros-D9o0YAQJ).
*Thank you, Liam!* 🙌🏻

0 comments on commit a410a19

Please sign in to comment.