Skip to content

Commit

Permalink
test: write test describing the current pseudo-element AST structure
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Jun 4, 2024
1 parent eb3e2a7 commit c6848e2
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/selectors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,52 @@ class SelectorsTest < Minitest::Spec
end
end

it "parses a compound selector with a pseudo-class" do
actual = parse_selectors("div.flex:hover")

assert_pattern do
actual => [
Selectors::CompoundSelector[
type: { value: { name: { value: "div" } } },
subclasses: [
Selectors::ClassSelector[value: { value: "flex" }],
Selectors::PseudoClassSelector[value: { value: "hover" }],
],
]
]
end
end

it "parses a compound selector with pseudo-elements and pseudo-classes" do
actual = parse_selectors("div.flex:hover::first-line:last-child::first-letter")

assert_pattern do
actual => [
Selectors::CompoundSelector[
type: { value: { name: { value: "div" } } },
subclasses: [
Selectors::ClassSelector[value: { value: "flex" }],
Selectors::PseudoClassSelector[value: { value: "hover" }],
],
pseudo_elements: [
[
Selectors::PseudoElementSelector[
Selectors::PseudoClassSelector[value: { value: "first-line" }],
],
[Selectors::PseudoClassSelector[value: { value: "last-child" }]],
],
[
Selectors::PseudoElementSelector[
Selectors::PseudoClassSelector[value: { value: "first-letter" }],
],
[],
]
]
]
]
end
end

it "parses a complex selector" do
actual = parse_selectors("section>table")

Expand Down

0 comments on commit c6848e2

Please sign in to comment.