Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.6 kB · 60 lines
Elixir
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061defmodule TrackerWeb.SectionHeaderTest do use TrackerWeb.ConnCase, async: true
import Phoenix.LiveViewTest import Phoenix.Component, only: [sigil_H: 2]
alias TrackerWeb.SectionHeader
describe "section_header/1" do test "renders the title, a rule, and the count" do assigns = %{}
html = rendered_to_string(~H""" <SectionHeader.section_header title="Packages" count={3} /> """)
assert html =~ ~s(class="section-header") assert html =~ "<h2>Packages</h2>" assert html =~ ~s(<span class="rule">) assert html =~ ~s(<span class="n">3</span>) end
test "renders without a count" do assigns = %{}
html = rendered_to_string(~H""" <SectionHeader.section_header title="Metadata" class="package-show__panel-header" /> """)
assert html =~ ~s(class="section-header package-show__panel-header") refute html =~ ~s(class="n") end
test "renders controls between the rule and the count" do assigns = %{}
html = rendered_to_string(~H""" <SectionHeader.section_header title="Revisions" count={3}> <:controls><button>Filter</button></:controls> </SectionHeader.section_header> """)
assert html =~ ~s(<span class="section-controls"><button>Filter</button></span>) end
test "omits the controls wrapper when no controls are given" do assigns = %{}
html = rendered_to_string(~H""" <SectionHeader.section_header title="Revisions" count={3} /> """)
refute html =~ "section-controls" end endend