Skip to content

Commit 259a52c

Browse files
committed
!3756 test(#I6AIZF): add unit test for table PageInfoTemplate parameter
* test: 增加 PageInfo 单元测试 * test: 增加 PageInfoTemplate 单元测试
1 parent d642520 commit 259a52c

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

test/UnitTest/Components/TableTest.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,57 @@ public void PageItems_Ok()
722722
Assert.Equal(20, table.Instance.PageItems);
723723
}
724724

725+
[Fact]
726+
public void PageInfoTemplate_Ok()
727+
{
728+
var localizer = Context.Services.GetRequiredService<IStringLocalizer<Foo>>();
729+
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
730+
{
731+
pb.AddChildContent<Table<Foo>>(pb =>
732+
{
733+
pb.Add(a => a.RenderMode, TableRenderMode.Table);
734+
pb.Add(a => a.IsPagination, true);
735+
pb.Add(a => a.OnQueryAsync, OnQueryAsync(localizer));
736+
pb.Add(a => a.PageItems, 20);
737+
pb.Add(a => a.ShowPageInfo, true);
738+
pb.Add(a => a.PageInfoTemplate, builder => builder.AddContent(0, "Test_PageInfoTemplate"));
739+
pb.Add(a => a.TableColumns, foo => builder =>
740+
{
741+
builder.OpenComponent<TableColumn<Foo, string>>(0);
742+
builder.AddAttribute(1, "Field", "Name");
743+
builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Name", typeof(string)));
744+
builder.CloseComponent();
745+
});
746+
});
747+
});
748+
Assert.Contains("Test_PageInfoTemplate", cut.Markup);
749+
}
750+
751+
[Fact]
752+
public void PageInfoText_Ok()
753+
{
754+
var localizer = Context.Services.GetRequiredService<IStringLocalizer<Foo>>();
755+
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
756+
{
757+
pb.AddChildContent<Table<Foo>>(pb =>
758+
{
759+
pb.Add(a => a.RenderMode, TableRenderMode.Table);
760+
pb.Add(a => a.IsPagination, true);
761+
pb.Add(a => a.OnQueryAsync, OnQueryAsync(localizer));
762+
pb.Add(a => a.PageItems, 20);
763+
pb.Add(a => a.PageInfoText, "Test_PageInfoText");
764+
pb.Add(a => a.TableColumns, foo => builder =>
765+
{
766+
builder.OpenComponent<TableColumn<Foo, string>>(0);
767+
builder.AddAttribute(1, "Field", "Name");
768+
builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Name", typeof(string)));
769+
builder.CloseComponent();
770+
});
771+
});
772+
});
773+
Assert.Contains("Test_PageInfoText", cut.Markup);
774+
}
775+
725776
[Fact]
726777
public void IsFixedHeader_Ok()
727778
{

0 commit comments

Comments
 (0)