Skip to content

Commit

Permalink
Move Slider tests out of ToDo and add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vnbaaij committed Nov 27, 2023
1 parent 13cef57 commit 04ffefb
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 5 deletions.
47 changes: 46 additions & 1 deletion examples/Demo/Shared/Pages/Lab/IssueTester.razor
Original file line number Diff line number Diff line change
@@ -1 +1,46 @@
@page "/IssueTester"
@page "/IssueTester"

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">
Current count: <FluentBadge Appearance="Appearance.Accent">@currentCount</FluentBadge>
</p>

<FluentButton Appearance="Appearance.Accent" @onclick="IncrementCount">Click me</FluentButton>

<br />
<br />

<EditForm Model="@Content" OnValidSubmit="@SaveAsync">
<FluentStack Orientation="Orientation.Vertical">
<FluentCheckbox @bind-Value=@Content.IsChecked>Check test</FluentCheckbox>
<FluentSwitch @bind-Value=Content.Switch CheckedMessage="On" UncheckedMessage="Off">
Switch test
</FluentSwitch>
<FluentButton Type="ButtonType.Submit" Appearance="Appearance.Accent">Submit</FluentButton>
</FluentStack>
</EditForm>

@code {
public class TestData
{
public string? Title { get; set; }

public bool IsChecked { get; set; }
public bool Switch { get; set; }
}

public TestData Content = new();

private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
private async Task SaveAsync()

Check warning on line 43 in examples/Demo/Shared/Pages/Lab/IssueTester.razor

View workflow job for this annotation

GitHub Actions / Build and deploy Demo site

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 43 in examples/Demo/Shared/Pages/Lab/IssueTester.razor

View workflow job for this annotation

GitHub Actions / Build and deploy Demo site

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 43 in examples/Demo/Shared/Pages/Lab/IssueTester.razor

View workflow job for this annotation

GitHub Actions / Build and deploy Demo site

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
}
}
2 changes: 1 addition & 1 deletion src/Core/Components/Slider/FluentSlider.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@attribute [CascadingTypeParameter(nameof(TValue))]
<FluentInputLabel ForId="@Id" Label="@Label" AriaLabel="@AriaLabel" style="margin-bottom: calc(var(--design-unit) * 3px);">@LabelTemplate</FluentInputLabel>
<fluent-slider @ref=Element
class="@($"{ClassValue} {Orientation.ToAttributeValue() ?? "horizontal"}")"
class="@($"{ClassValue} {Orientation.ToAttributeValue() ?? "horizontal"}".Trim())"
style="@StyleValue"
readonly="@ReadOnly"
min="@FormatValueAsString(Min)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,11 @@

</ItemGroup>

<ItemGroup>
<None Update="Slider\FluentSliderTests.FluentButton_Title.verified.razor.html">
<ParentFile>$([System.String]::Copy('%(FileName)').Split('.')[0])</ParentFile>
<DependentUpon>FluentSliderTests.razor</DependentUpon>
</None>
</ItemGroup>

</Project>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

<fluent-button type="button" aria-label="My Title" title="My Title" blazor:onclick="1" appearance="neutral" blazor:elementreference="8a9c23b1-ac50-4d7f-8bac-3bde51902752">My button</fluent-button>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<label for="xxx" class="fluent-input-label" style="margin-bottom: calc(var(--design-unit) * 3px);" b-ijcaj0p60b="">
</label>
<fluent-slider min="0" max="0" step="0" id="xxx" value="0" blazor:onchange="1" blazor:elementreference="xxx">
<fluent-slider class="horizontal" min="0" max="0" step="0" id="xxx" value="0" blazor:onchange="1" blazor:elementreference="xxx">
<b>render me</b>
</fluent-slider>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<label for="xxx" class="fluent-input-label" style="margin-bottom: calc(var(--design-unit) * 3px);" b-hum22yrq17="">
</label>
<fluent-slider class="horizontal" min="-1.5" max="7" step="0.5" id="xxx" value="0" blazor:onchange="1" blazor:elementreference="xxx"></fluent-slider>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<label for="xxx" class="fluent-input-label" style="margin-bottom: calc(var(--design-unit) * 3px);" b-hum22yrq17="">
</label>
<fluent-slider class="horizontal" min="0" max="100" step="10" id="xxx" value="0" blazor:onchange="1" blazor:elementreference="xxx"></fluent-slider>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<label for="xxx" class="fluent-input-label" style="margin-bottom: calc(var(--design-unit) * 3px);" b-hum22yrq17="">
</label>
<fluent-slider class="horizontal" min="0" max="100" step="10" id="xxx" value="0" blazor:onchange="1" blazor:elementreference="xxx"></fluent-slider>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

<label for="xxx" class="fluent-input-label" style="margin-bottom: calc(var(--design-unit) * 3px);" b-hum22yrq17="">
</label>
<fluent-slider class="vertical" min="0" max="100" step="10" orientation="vertical" id="xxx" value="0" blazor:onchange="1" blazor:elementreference="xxx"></fluent-slider>
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
namespace Microsoft.FluentUI.AspNetCore.Components.Tests.Slider;


public class FluentSliderTests: TestBase
{
public partial class FluentSliderTests: TestContext
{
private TestContext TestContext => new(); // TODO: To remove and to use the `RenderComponent` inherited method.

[Fact]
public void FluentSlider_Default()
{
Expand Down
46 changes: 46 additions & 0 deletions tests/Core/Slider/FluentSliderTests.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@using Xunit;
@inherits TestContext
@code
{
[Fact]
public void FluentSlider_HorizontalImplicit()
{
// Arrange && Act
var cut = Render(@<FluentSlider Min="0" Max="100" Step="10"></FluentSlider>);

// Assert
cut.Verify();
}

[Fact]
public void FluentSlider_Horizontal()
{
// Arrange && Act
var cut = Render(@<FluentSlider Min="0" Max="100" Step="10"></FluentSlider>);

// Assert
cut.Verify();
}

[Fact]
public void FluentSlider_Vertical()
{

// Arrange
var cut = Render(@<FluentSlider Min="0" Max="100" Step="10" Orientation="Orientation.Vertical"></FluentSlider>);

// Assert
cut.Verify();
}

[Fact]
public void FluentSlider_Double()
{
double value = 3.5;
// Arrange
var cut = Render(@<FluentSlider Min="-1.50" Max="7.0" Step="0.5" @bind-bind-Value="@value"></FluentSlider>);

// Assert
cut.Verify();
}
}

0 comments on commit 04ffefb

Please sign in to comment.