Skip to content

Commit be414e5

Browse files
committed
Add group all test
1 parent e9285b7 commit be414e5

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

test/api-groups.js

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ const assert = require("assert"),
99

1010
describe("/lib", () => {
1111
describe("/pseudo.js", () => {
12+
// all
13+
it("should run posthtml with pseudo using group all", () =>
14+
posthtml()
15+
.use(pseudo({ include : "all" }))
16+
.process(fixtures.groups.all.input)
17+
.then((result) => {
18+
assert.equal(result.html, fixtures.groups.all.expected);
19+
})
20+
);
21+
1222
// firstLastOnly
1323
it("should run posthtml with pseudo using group firstLastOnly", () =>
1424
posthtml()

test/fixtures/groups/all.expected.html

+14-14
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,47 @@
44
<title>page title</title>
55
</head>
66
<body>
7-
<h1 class=":first-child :last-of-type :only-of-type">header</h1>
7+
<h1 class=":first-child :first-of-type :last-of-type :only-of-type">header</h1>
88
<form action="#" class=":first-of-type :last-of-type :only-of-type">
9-
<input type="text" placeholder="Name" disabled="" class=":disabled :empty :first-child :optional :read-write">
9+
<input type="text" placeholder="Name" disabled="" class=":disabled :empty :first-child :first-of-type :optional :read-write">
1010
<input type="text" placeholder="Address" readonly="" class=":empty :enabled :optional :read-only">
1111
<input class="zipcode :disabled :empty :read-write :required" type="text" placeholder="Zip Code" disabled="" required="">
1212

1313
<input class="submit :empty :enabled :last-of-type :optional :read-only" type="submit" name="" value="submit" readonly="readonly">
1414

1515
<select readonly="" class=":enabled :first-of-type :last-of-type :only-of-type :optional :read-only">
16-
<option class="first-child">option 1</option>
17-
<option>option 2</option>
18-
<option>option 3</option>
16+
<option class=":enabled :first-child :first-of-type">option 1</option>
17+
<option class=":enabled">option 2</option>
18+
<option class=":enabled :last-child :last-of-type">option 3</option>
1919
</select>
2020

2121
<textarea class=":empty :enabled :first-of-type :last-of-type :only-of-type :optional :read-write"></textarea>
2222

23-
<button type="button" class=":enabled :first-of-type :last-child :last-of-type :only-of-type">Button</button>
23+
<button type="button" class=":enabled :first-of-type :last-child :last-of-type :only-of-type :optional">Button</button>
2424
</form>
2525

2626
<div class=":first-of-type">
2727
outer
28-
<div class=":first-child :last-child :last-of-type :only-child">Inner</div>
28+
<div class=":first-child :first-of-type :last-child :last-of-type :only-child :only-of-type">Inner</div>
2929
</div>
3030

3131
<div class=":empty :last-of-type"></div>
3232

33-
<button type="button" disabled="" class=":disabled :first-of-type :last-of-type">Button 2</button>
33+
<button type="button" disabled="" class=":disabled :first-of-type :last-of-type :only-of-type :optional">Button 2</button>
3434

35-
<ul class=":first-of-type :last-of-type">
35+
<ul class=":first-of-type :last-of-type :only-of-type">
3636
<li class=":first-child :first-of-type">list 1</li>
3737
<li>
3838
list 2
39-
<ul class=":first-child :first-of-type :last-child :last-of-type :only-child">
40-
<li class=":first-child">l2 - 1</li>
39+
<ul class=":first-child :first-of-type :last-child :last-of-type :only-child :only-of-type">
40+
<li class=":first-child :first-of-type">l2 - 1</li>
4141
<li>l2 - 2</li>
4242
<li class="hr :empty :last-child :last-of-type"></li>
4343
</ul>
4444
</li>
4545
<li class=":last-child :last-of-type">
46-
<p class=":first-child :first-of-type :last-child :last-of-type :only-child">
47-
The number of lines in a paragraph depends on the size of the browser window. If you resize <a href="#test" class=":first-child :last-child :last-of-type">the browser</a> window, the number of lines in this paragraph will change.
46+
<p class=":first-child :first-of-type :last-child :last-of-type :only-child :only-of-type">
47+
The number of lines in a paragraph depends on the size of the browser window. If you resize <a href="#test" class=":enabled :first-child :first-of-type :last-child :last-of-type :only-child :only-of-type">the browser</a> window, the number of lines in this paragraph will change.
4848
</p>
4949
</li>
5050
</ul>
@@ -55,7 +55,7 @@ <h1 class=":first-child :last-of-type :only-of-type">header</h1>
5555
in the source code,
5656
but the browser
5757
ignores it.
58-
<a class=":first-child :first-of-type :last-child :last-of-type">no href</a> and <a href="">empty href</a>
58+
<a class=":first-child :first-of-type">no href</a> and <a href="" class=":enabled :last-child :last-of-type">empty href</a>
5959
</p>
6060

6161
<p>

test/fixtures/groups/all.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h1>header</h1>
88
<form action="#">
99
<input type="text" placeholder="Name" disabled>
1010
<input type="text" placeholder="Address" readonly>
11-
<input class="zipcode" type="text" placeholder="Zip Code" required>
11+
<input class="zipcode" type="text" placeholder="Zip Code" disabled required>
1212

1313
<input class="submit" type="submit" name="" value="submit" readonly="readonly">
1414

0 commit comments

Comments
 (0)