Skip to content

Commit

Permalink
Add test for Element::InsertBefore
Browse files Browse the repository at this point in the history
  • Loading branch information
mikke89 committed Aug 24, 2024
1 parent 193d3e6 commit c02fac6
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions Tests/Source/UnitTests/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,12 @@ TEST_CASE("Element")
context->Update();
context->Render();

TestsShell::RenderLoop();
Element* div = document->GetFirstChild();
Element* span = div->GetChild(1);
REQUIRE(div);
REQUIRE(div->GetTagName() == "div");
REQUIRE(span);
REQUIRE(span->GetTagName() == "span");

SUBCASE("Attribute")
{
Expand Down Expand Up @@ -295,12 +300,6 @@ TEST_CASE("Element")
SUBCASE("GetInnerRML")
{
String inner_rml;
Element* div = document->GetFirstChild();
Element* span = div->GetChild(1);
REQUIRE(div);
REQUIRE(div->GetTagName() == "div");
REQUIRE(span);
REQUIRE(span->GetTagName() == "span");

inner_rml = document->GetInnerRML();
CHECK(inner_rml == R"(<div style="background-color: #ff0000;">This is a <span>sample</span>.</div>)");
Expand All @@ -322,6 +321,18 @@ TEST_CASE("Element")
CHECK(inner_rml == R"(<div style="cursor: x&lt;y;">This is a <span style="font-weight: bold;">sample</span>.</div>)");
}

SUBCASE("InsertBefore")
{
String inner_rml;

inner_rml = document->GetInnerRML();
CHECK(inner_rml == R"(<div style="background-color: #ff0000;">This is a <span>sample</span>.</div>)");

div->InsertBefore(document->CreateElement("img"), span);
inner_rml = document->GetInnerRML();
CHECK(inner_rml == R"(<div style="background-color: #ff0000;">This is a <img /><span>sample</span>.</div>)");
}

document->Close();
TestsShell::ShutdownShell();
}
Expand Down

0 comments on commit c02fac6

Please sign in to comment.