Skip to content

Commit

Permalink
refactoring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eebbesen committed Dec 19, 2024
1 parent fd69031 commit 8a284ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion StpFoodBlazor/StpFoodBlazor/Components/Pages/Deals.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
<div class="container mb-5">
<DealFilterBar selectedDayOfWeek="@selectedDayOfWeek" OnSelectedDayChanged="OnSelectedDayChanged"
happyHour="@happyHour" OnHappyHourChanged="OnHappyHourChanged" />
<DealTableHeader selectedDayOfWeek="@selectedDayOfWeek" />
@if (deals == null)
{
<DealTableHeader selectedDayOfWeek="@TimeServiceImpl.GetDayOfWeek()" />
<DealTableBodyPlaceholder />
}
else
{
<DealTableHeader selectedDayOfWeek="@selectedDayOfWeek" />
<DealTableBody deals="@deals" selectedDayOfWeek="@selectedDayOfWeek" />
}
</div>
Expand Down
8 changes: 4 additions & 4 deletions StpFoodBlazor/StpFoodBlazorTest/Pages/DealsTest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
ctx.Services.AddSingleton<IDealService>(testDealService);

var cut = ctx.Render(@<Deals />);
cut.WaitForElement("#deals_table_body_placeholder");
var elements = cut.Find("#deals_table_body_placeholder");
var header = cut.WaitForElement("#deals_table_header");
var elements = cut.WaitForElement("#deals_table_body_placeholder");

Assert.Equal("Place", header.Children[0].InnerHtml);
Assert.Equal(30, elements.ChildElementCount);
Assert.Equal("<span class=\"col-12 rounded placeholder bg-white\">&nbsp;</span>",
elements.Children[0].InnerHtml);
Expand Down Expand Up @@ -188,7 +189,6 @@

private IElement getElements(IRenderedFragment cut)
{
cut.WaitForElement("#deals_table_body", TimeSpan.FromSeconds(5));
return cut.Find("#deals_table_body");
return cut.WaitForElement("#deals_table_body", TimeSpan.FromSeconds(5));
}
}
8 changes: 4 additions & 4 deletions StpFoodBlazor/StpFoodBlazorTest/Pages/GiftCardsTest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
ctx.Services.AddSingleton<IGiftCardService>(testGiftCardService);

var cut = ctx.Render(@<GiftCards />);
cut.WaitForElement("#giftcards_table_body_placeholder");
var elements = cut.Find("#giftcards_table_body_placeholder");
var header = cut.WaitForElement("#giftcards_table_header");
var elements = cut.WaitForElement("#giftcards_table_body_placeholder");

Assert.Equal("Place", header.Children[0].InnerHtml);
Assert.Equal(30, elements.ChildElementCount);
Assert.Equal("<span class=\"col-12 rounded placeholder bg-white\">&nbsp;</span>",
elements.Children[0].InnerHtml);
Expand Down Expand Up @@ -74,7 +75,6 @@

private IElement getElements(IRenderedFragment cut)
{
cut.WaitForElement("#giftcards_table_body", TimeSpan.FromSeconds(5));
return cut.Find("#giftcards_table_body");
return cut.WaitForElement("#giftcards_table_body", TimeSpan.FromSeconds(5));
}
}

0 comments on commit 8a284ad

Please sign in to comment.