mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-02 03:59:14 +08:00
test(Table): add unit test for table (#383)
* refactor: update pagination code * test: update OnConfirm unit test
This commit is contained in:
parent
60ed1d7a7c
commit
374b62b5ac
@ -732,7 +732,10 @@ public partial class Table<TItem>
|
||||
// https://gitee.com/LongbowEnterprise/BootstrapBlazor/issues/I1UJSL
|
||||
PageIndex = Math.Max(1, Math.Min(PageIndex, int.Parse(Math.Ceiling((TotalCount - SelectedRows.Count) * 1d / PageItems).ToString())));
|
||||
var items = PageItemsSource.Where(item => item >= (TotalCount - SelectedRows.Count));
|
||||
PageItems = Math.Min(PageItems, items.Any() ? items.Min() : PageItems);
|
||||
if (items.Any())
|
||||
{
|
||||
PageItems = Math.Min(PageItems, items.Min());
|
||||
}
|
||||
}
|
||||
SelectedRows.Clear();
|
||||
await QueryAsync();
|
||||
|
@ -5191,7 +5191,7 @@ public class TableTest : TableTestBase
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task OnConfirm_Ok()
|
||||
public void OnConfirm_Ok()
|
||||
{
|
||||
var localizer = Context.Services.GetRequiredService<IStringLocalizer<Foo>>();
|
||||
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
|
||||
@ -5219,14 +5219,14 @@ public class TableTest : TableTestBase
|
||||
var deleteButton = table.FindComponent<TableToolbarPopconfirmButton<Foo>>();
|
||||
// 选一个
|
||||
var input = cut.Find("tbody tr input");
|
||||
await cut.InvokeAsync(() => input.Click());
|
||||
await cut.InvokeAsync(() => deleteButton.Instance.OnConfirm());
|
||||
cut.InvokeAsync(() => input.Click());
|
||||
cut.InvokeAsync(() => deleteButton.Instance.OnConfirm());
|
||||
|
||||
table.SetParametersAndRender(pb =>
|
||||
{
|
||||
pb.Add(a => a.PageItemsSource, new int[] { 1, 2, 4, 8 });
|
||||
});
|
||||
await cut.InvokeAsync(() => deleteButton.Instance.OnConfirm());
|
||||
cut.InvokeAsync(() => deleteButton.Instance.OnConfirm());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -6357,7 +6357,7 @@ public class TableTest : TableTestBase
|
||||
return Task.FromResult(new QueryData<Foo>()
|
||||
{
|
||||
Items = items,
|
||||
TotalCount = 80,
|
||||
TotalCount = 5,
|
||||
IsAdvanceSearch = isAdvanceSearch,
|
||||
IsFiltered = isFilter,
|
||||
IsSearch = isSearch,
|
||||
|
Loading…
Reference in New Issue
Block a user