ant-design-blazor/tests/AntDesign.Tests/button/ButtonTests.razor
Key Roche 4ad8e7ceab
docs: enhance documentation automation (#3013)
* Documentation automation. Build will generate documentation based on XML comments and attributes in the library. Translation will be done where necessary to generate the Chineese site.

Did some small code clean up on the way.
Removed or removed from public APIs:

AnchorLink.LinkDom
Button.RemoveAnimationAfter
Button.Icons - never used
Calendar.PrefixCls
All date pickers - method OnOkClick
Descriptions.Items
ListItem.PrefixName
AntList.PrefixName
ListItemMeta.PrefixName
Menu.Submenus
Menu.MenuItems
Transfer.ChildContent
Table.ColumnContext
Space.SetClass
Steps.Handler
Radio.OnClick

* Add Azure translation service. Requires adding your own key to a private appsettings JSON file to translate locally with it.

* Make translation services return null when unable to translate, have cache not cache it and return text asked to translate.

* Update documentation markdown file for new translation service

* Update DOCUMENTATION.md

* fix datepickerbase

* fix tree-select

* add docs for Flex and Watermark

* add zh

* add UserSecrets

* fix keywords

* fix button doc

* fix page

* fix internals visible to

---------

Co-authored-by: James Yeung <shunjiey@hotmail.com>
2024-08-25 14:37:41 +08:00

97 lines
4.0 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@inherits AntDesignTestBase
@code {
[Fact]
public void Renders_a_color_button()
{
var cut = Render<Button>(@<Button Color="Color.Red3"></Button> );
cut.MarkupMatches(@<button class="ant-btn ant-btn-default" style="background-color: #ffa39e; border-color: #ffa39e; color: rgba(0,0,0,0.85);" id:ignore type="button" ant-click-animating-without-extra-node="false" ></button>);
}
[Fact]
public void Ignore_link_animation_when_cliked_using_nonprimary_mouse_button()
{
var cut = Render<Button>(@<Button Type="@ButtonType.Default"/>);
cut.Find("button").MouseUp(new MouseEventArgs
{
Button = 2
});
cut.MarkupMatches(@<button class="ant-btn ant-btn-default" id:ignore type="button" ant-click-animating-without-extra-node="false"></button>);
}
[Fact]
public void Link_animation_when_cliked_using_primary_mouse_button()
{
var cut = Render<Button>(@<Button Type="@ButtonType.Default"/>
);
cut.Find("button").MouseUp(new MouseEventArgs
{
Button = 0
});
cut.MarkupMatches(@<button class="ant-btn ant-btn-default" id:ignore type="button" ant-click-animating-without-extra-node="true"></button>);
}
[Fact]
public async Task Button_animation_when_cliked_end_after_some_time()
{
var cut = Render<Button>(@<Button Type="@ButtonType.Default"/>);
cut.Find("button").MouseUp(new MouseEventArgs
{
Button = 0
});
cut.MarkupMatches(@<button class="ant-btn ant-btn-default" id:ignore type="button" ant-click-animating-without-extra-node="true"></button>);
await Task.Delay(550);
cut.MarkupMatches(@<button class="ant-btn ant-btn-default" id:ignore type="button" ant-click-animating-without-extra-node="false"></button>);
}
class Model
{
public string? Name { get; set; }
}
[Fact]
public void Receives_size_from_Form()
{
JSInterop.Setup<Window>(JSInteropConstants.DomInfoHelper.GetWindow, _ => true).SetResult(new Window());
Model _model = new() { Name = "modelValue" };
var cut = Render<AntDesign.Form<Model>>(
@<AntDesign.Form Model="@_model" Size="small">
<AntDesign.FormItem Label="Test">
<AntDesign.Button>Test</AntDesign.Button>
</AntDesign.FormItem>
</AntDesign.Form>
);
var button = cut.FindComponent<AntDesign.Button>();
cut.Instance.Size.Should().Be("small");
cut.Instance.Size.Should().Be(cut.Instance.Size);
button.Instance.FormSize.Should().Be("small");
}
[Fact]
public void Loading_is_rendering()
{
var cut = Render<AntDesign.Button>(@<Button Loading>Test</Button>);
cut.MarkupMatches(@<button class="ant-btn ant-btn-default ant-btn-loading" id:ignore type="button" ant-click-animating-without-extra-node="false">
  <span class="ant-btn-loading-icon">
<span role="img" class=" anticon anticon-loading" id:ignore>
<svg focusable="false" width="1em" height="1em" fill="currentColor" style="pointer-events: none;" class="anticon-spin" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
<path d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 0 0-94.3-139.9 437.71 437.71 0 0 0-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"></path>
</svg>
</span>
</span>
<span>Test</span>
</button>);
}
[Fact]
public void Should_wrap_in_span_when_NoSpanWrap_set_to_true()
{
var cut = Render<AntDesign.Button>(@<AntDesign.Button NoSpanWrap="false">Test</AntDesign.Button>);
cut.MarkupMatches(@<button class="ant-btn ant-btn-default" id:ignore type="button" ant-click-animating-without-extra-node="false">
  <span>Test</span>
</button>);
}
}