mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-04 21:20:16 +08:00
!3734 test(#I69C64): update unit test for ITableExportAsync
* test: 增加 ITableExportContext 单元测试 * doc: 精简示例 * test: 增加 IsTimeSpan 单元测试
This commit is contained in:
parent
68641880f3
commit
cae475e58b
@ -62,7 +62,7 @@
|
||||
<TableColumn @bind-Field="@context.Count" />
|
||||
</TableColumns>
|
||||
<ExportButtonDropdownTemplate Context="ExportContext">
|
||||
<div class="dropdown-item" @onclick="() => ExcelExportAsync(ExportContext)">
|
||||
<div class="dropdown-item" @onclick="ExportContext.ExportAsync">
|
||||
<i class="fa-regular fa-file-excel"></i>
|
||||
<span>MS-Excel</span>
|
||||
</div>
|
||||
|
@ -58,7 +58,5 @@ public partial class TablesExport
|
||||
|
||||
private static Task<bool> OnExportAsync(IEnumerable<Foo> Items, QueryPageOptions options) => Task.FromResult(true);
|
||||
|
||||
private static Task ExcelExportAsync(ITableExportContext<Foo> context) => context.ExportAsync();
|
||||
|
||||
private Task CsvExportAsync() => ToastService.Success("CSV export", "Export CSV data successfully");
|
||||
}
|
||||
|
@ -577,6 +577,7 @@ public class TableTest : TableTestBase
|
||||
[Fact]
|
||||
public void ExportButtonDropdownTemplate_Ok()
|
||||
{
|
||||
ITableExportContext<Foo>? context = null;
|
||||
var localizer = Context.Services.GetRequiredService<IStringLocalizer<Foo>>();
|
||||
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
|
||||
{
|
||||
@ -585,8 +586,9 @@ public class TableTest : TableTestBase
|
||||
pb.Add(a => a.ShowToolbar, true);
|
||||
pb.Add(a => a.ShowExportButton, true);
|
||||
pb.Add(a => a.ExportButtonText, "Test_Export");
|
||||
pb.Add(a => a.ExportButtonDropdownTemplate, builder =>
|
||||
pb.Add(a => a.ExportButtonDropdownTemplate, c => builder =>
|
||||
{
|
||||
context = c;
|
||||
builder.OpenElement(0, "div");
|
||||
builder.AddContent(1, "test-export-dropdown-item");
|
||||
builder.CloseElement();
|
||||
@ -602,6 +604,13 @@ public class TableTest : TableTestBase
|
||||
});
|
||||
});
|
||||
cut.Contains("test-export-dropdown-item");
|
||||
Assert.NotNull(context);
|
||||
|
||||
Assert.Single(context.Columns);
|
||||
Assert.Single(context.GetVisibleColumns());
|
||||
Assert.NotNull(context.BuildQueryPageOptions());
|
||||
Assert.Equal(80, context.Rows.Count());
|
||||
Assert.NotNull(context.ExportAsync());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -56,6 +56,16 @@ public class ObjectExtensionsTest
|
||||
Assert.Equal(expect, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(typeof(TimeSpan?), true)]
|
||||
[InlineData(typeof(TimeSpan), true)]
|
||||
[InlineData(typeof(string), false)]
|
||||
public static void IsTimeSpan_Ok(Type source, bool expect)
|
||||
{
|
||||
var actual = source.IsTimeSpan();
|
||||
Assert.Equal(expect, actual);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(typeof(SortOrder), "枚举")]
|
||||
[InlineData(typeof(int), "数字")]
|
||||
|
Loading…
Reference in New Issue
Block a user