Skip to content

Commit

Permalink
test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
eebbesen committed Dec 19, 2024
1 parent a41d097 commit b963d24
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
26 changes: 19 additions & 7 deletions StpFoodBlazor/StpFoodBlazorTest/Pages/DealsTest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
ctx.Services.AddSingleton<ITimeService>(timeService);
}

@* public void Dispose(){
// so that TestDealService attributes are reset
} *@

[Fact]
public void DealsShouldDisplayPlaceholderWhenLoading()
{
Expand Down Expand Up @@ -98,7 +102,8 @@
{
ctx.Services.AddSingleton<ITimeService>(timeService);
var cut = ctx.Render(@<Deals />);
var dowSelect = (IHtmlSelectElement)cut.WaitForElement("#day-of-week-select");
cut.WaitForElement("#day-of-week-select");
var dowSelect = (IHtmlSelectElement)cut.Find("#day-of-week-select");
getElements(cut); // just to make sure table is rendered
Assert.Equal(DateTime.Today.DayOfWeek.ToString(), dowSelect.Value);
Expand All @@ -108,9 +113,11 @@
public void DealsShouldChangeWhenNewValueSelectedMonday()
{
var cut = ctx.Render(@<Deals />);
var dowSelect = (IHtmlSelectElement)cut.WaitForElement("#day-of-week-select");
cut.WaitForElement("#day-of-week-select");
var dowSelect = (IHtmlSelectElement)cut.Find("#day-of-week-select");

dowSelect.Change("Monday");
@* cut.WaitForState(() => cut.Find("#day-of-week-select").TextContent == "Monday"); *@

var elements = getElements(cut);
Assert.Equal(16, elements.ChildElementCount);
Expand All @@ -120,7 +127,8 @@
public void DealsShouldChangeWhenNewValueSelectedFriday()
{
var cut = ctx.Render(@<Deals />);
var dowSelect = (IHtmlSelectElement)cut.WaitForElement("#day-of-week-select");
cut.WaitForElement("#day-of-week-select");
var dowSelect = (IHtmlSelectElement)cut.Find("#day-of-week-select");

dowSelect.Change("Friday");

Expand All @@ -132,7 +140,8 @@
public void DealsShouldSortByDay()
{
var cut = ctx.Render(@<Deals />);
var dowSelect = (IHtmlSelectElement)cut.WaitForElement("#day-of-week-select");
cut.WaitForElement("#day-of-week-select");
var dowSelect = (IHtmlSelectElement)cut.Find("#day-of-week-select");

dowSelect.Change(""); // All value in the select is ""
Expand All @@ -146,7 +155,8 @@
public void DealsShouldShowDayColumnWhenAllDays()
{
var cut = ctx.Render(@<Deals />);
var dowSelect = (IHtmlSelectElement)cut.WaitForElement("#day-of-week-select");
cut.WaitForElement("#day-of-week-select");
var dowSelect = (IHtmlSelectElement)cut.Find("#day-of-week-select");

dowSelect.Change(""); // All value in the select is ""
Expand All @@ -161,7 +171,8 @@
public void DealsShouldNotShowDayColumnWhenNotAllDays()
{
var cut = ctx.Render(@<Deals />);
var dowSelect = (IHtmlSelectElement)cut.WaitForElement("#day-of-week-select");
cut.WaitForElement("#day-of-week-select");
var dowSelect = (IHtmlSelectElement)cut.Find("#day-of-week-select");

dowSelect.Change("Friday");

Expand Down Expand Up @@ -191,6 +202,7 @@

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

public void Dispose(){

Check warning on line 20 in StpFoodBlazor/StpFoodBlazorTest/Pages/GiftCardsTest.razor

View workflow job for this annotation

GitHub Actions / build

Public method 'Dispose' on test class 'GiftCardsTest' should be marked as a Fact. Reduce the visibility of the method, or add a Fact attribute to the method. (https://xunit.net/xunit.analyzers/rules/xUnit1013)

Check warning on line 20 in StpFoodBlazor/StpFoodBlazorTest/Pages/GiftCardsTest.razor

View workflow job for this annotation

GitHub Actions / build

Public method 'Dispose' on test class 'GiftCardsTest' should be marked as a Fact. Reduce the visibility of the method, or add a Fact attribute to the method. (https://xunit.net/xunit.analyzers/rules/xUnit1013)
// so that TestDealService attributes are reset
}

[Fact]
public void GiftCardsShouldDisplayPlaceholderWhenLoading()
{
Expand Down

0 comments on commit b963d24

Please sign in to comment.