mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-12-05 21:50:05 +08:00
!3546 fix(#I61S09): can't reload the data call QueryAsync method on ListView component
* test: 增加 QueryAsync 单元测试 * test: 消除警告信息 * fix: 修复重新查询失败问题
This commit is contained in:
parent
58ab24cd06
commit
1de8ecc8f1
@ -112,12 +112,9 @@ public partial class ListView<TItem> : BootstrapComponentBase where TItem : clas
|
||||
/// <returns></returns>
|
||||
public async Task QueryAsync(int pageIndex = 1)
|
||||
{
|
||||
if (pageIndex != PageIndex)
|
||||
{
|
||||
PageIndex = pageIndex;
|
||||
await QueryData();
|
||||
StateHasChanged();
|
||||
}
|
||||
PageIndex = pageIndex;
|
||||
await QueryData();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -353,7 +353,7 @@ public class ButtonTest : BootstrapBlazorTestBase
|
||||
});
|
||||
});
|
||||
cut.Contains("button type=\"button\"");
|
||||
cut.InvokeAsync(async () => await cut.Instance.OnClickWithoutRender());
|
||||
cut.InvokeAsync(async () => await cut.Instance.OnClickWithoutRender!.Invoke());
|
||||
Assert.True(clicked);
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class IPLocatorTest : BootstrapBlazorTestBase
|
||||
|
||||
private class MockLogger : ILogger<IIPLocatorProvider>
|
||||
{
|
||||
public IDisposable BeginScope<TState>(TState state) => throw new NotImplementedException();
|
||||
public IDisposable? BeginScope<TState>(TState state) where TState : notnull => throw new NotImplementedException();
|
||||
|
||||
public bool IsEnabled(LogLevel logLevel) => true;
|
||||
|
||||
|
@ -77,6 +77,38 @@ public class ListViewTest : BootstrapBlazorTestBase
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void QueryAsync_Ok()
|
||||
{
|
||||
bool query = false;
|
||||
var items = Enumerable.Range(1, 6).Select(i => new Product()
|
||||
{
|
||||
ImageUrl = $"images/Pic{i}.jpg",
|
||||
Description = $"Pic{i}.jpg",
|
||||
Category = $"Group{(i % 4) + 1}"
|
||||
});
|
||||
var cut = Context.RenderComponent<ListView<Product>>(pb =>
|
||||
{
|
||||
pb.Add(a => a.OnQueryAsync, option =>
|
||||
{
|
||||
query = true;
|
||||
var ret = new QueryData<Product>()
|
||||
{
|
||||
Items = items,
|
||||
TotalCount = 6
|
||||
};
|
||||
return Task.FromResult(ret);
|
||||
});
|
||||
pb.Add(a => a.Pageable, true);
|
||||
pb.Add(a => a.PageItems, 2);
|
||||
});
|
||||
Assert.True(query);
|
||||
|
||||
query = false;
|
||||
cut.InvokeAsync(() => cut.Instance.QueryAsync());
|
||||
Assert.True(query);
|
||||
}
|
||||
|
||||
private class Product
|
||||
{
|
||||
public string? ImageUrl { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user