!2750 test(#I55NYC): add unit test for pagination of Table

* test: 增加翻页操作单元测试
* refactor: 增加行号资源文件
This commit is contained in:
Argo 2022-05-04 08:02:14 +00:00
parent f6fcc4e024
commit 0779c5f486
7 changed files with 39 additions and 1 deletions

View File

@ -325,5 +325,6 @@ public partial class Table<TItem>
SortAscText ??= Localizer[nameof(SortAscText)]; SortAscText ??= Localizer[nameof(SortAscText)];
SortDescText ??= Localizer[nameof(SortDescText)]; SortDescText ??= Localizer[nameof(SortDescText)];
EmptyText ??= Localizer[nameof(EmptyText)]; EmptyText ??= Localizer[nameof(EmptyText)];
LineNoText ??= Localizer[nameof(LineNoText)];
} }
} }

View File

@ -30,7 +30,8 @@ public partial class Table<TItem>
/// 获得/设置 行号列标题文字 默认为 行号 /// 获得/设置 行号列标题文字 默认为 行号
/// </summary> /// </summary>
[Parameter] [Parameter]
public string LineNoText { get; set; } = "行号"; [NotNull]
public string? LineNoText { get; set; }
private bool PageItemsSourceChanged { get; set; } private bool PageItemsSourceChanged { get; set; }

View File

@ -223,6 +223,7 @@
"CheckboxDisplayText": "Alle", "CheckboxDisplayText": "Alle",
"EditModalTitle": "Bearbeiten", "EditModalTitle": "Bearbeiten",
"AddModalTitle": "Neu", "AddModalTitle": "Neu",
"LineNoText": "Zeilen",
"ColumnButtonTemplateHeaderText": "", "ColumnButtonTemplateHeaderText": "",
"SearchTooltip": "<div class='search-input-tooltip'>Bitte eingeben ...</br><kbd>Enter</kbd> Suche <kbd>ESC</kbd> Leeren</div>", "SearchTooltip": "<div class='search-input-tooltip'>Bitte eingeben ...</br><kbd>Enter</kbd> Suche <kbd>ESC</kbd> Leeren</div>",
"SearchModalTitle": "Suche", "SearchModalTitle": "Suche",

View File

@ -223,6 +223,7 @@
"CheckboxDisplayText": "All", "CheckboxDisplayText": "All",
"EditModalTitle": "Edit", "EditModalTitle": "Edit",
"AddModalTitle": "New", "AddModalTitle": "New",
"LineNoText": "No.",
"ColumnButtonTemplateHeaderText": "", "ColumnButtonTemplateHeaderText": "",
"SearchTooltip": "<div class='search-input-tooltip'>Please input ...</br><kbd>Enter</kbd> Search <kbd>ESC</kbd> Clear</div>", "SearchTooltip": "<div class='search-input-tooltip'>Please input ...</br><kbd>Enter</kbd> Search <kbd>ESC</kbd> Clear</div>",
"SearchModalTitle": "Searching", "SearchModalTitle": "Searching",

View File

@ -223,6 +223,7 @@
"CheckboxDisplayText": "Todos", "CheckboxDisplayText": "Todos",
"EditModalTitle": "Editar Registro", "EditModalTitle": "Editar Registro",
"AddModalTitle": "Novo Registro", "AddModalTitle": "Novo Registro",
"LineNoText": "Número",
"ColumnButtonTemplateHeaderText": "", "ColumnButtonTemplateHeaderText": "",
"SearchTooltip": "<div class='search-input-tooltip'>Tecle ...</br><kbd>Enter</kbd> Pesquisar <kbd>ESC</kbd> Limpar</div>", "SearchTooltip": "<div class='search-input-tooltip'>Tecle ...</br><kbd>Enter</kbd> Pesquisar <kbd>ESC</kbd> Limpar</div>",
"SearchModalTitle": "Procurando", "SearchModalTitle": "Procurando",

View File

@ -223,6 +223,7 @@
"CheckboxDisplayText": "选择", "CheckboxDisplayText": "选择",
"EditModalTitle": "编辑窗口", "EditModalTitle": "编辑窗口",
"AddModalTitle": "新建窗口", "AddModalTitle": "新建窗口",
"LineNoText": "行号",
"ColumnButtonTemplateHeaderText": "操作", "ColumnButtonTemplateHeaderText": "操作",
"SearchTooltip": "<div class='search-input-tooltip'>输入任意字符串全局搜索</br><kbd>Enter</kbd> 搜索 <kbd>ESC</kbd> 清除搜索</div>", "SearchTooltip": "<div class='search-input-tooltip'>输入任意字符串全局搜索</br><kbd>Enter</kbd> 搜索 <kbd>ESC</kbd> 清除搜索</div>",
"SearchModalTitle": "搜索条件", "SearchModalTitle": "搜索条件",

View File

@ -403,6 +403,38 @@ public class TableTest : TableTestBase
} }
} }
[Fact]
public async Task PageItemsSource_Ok()
{
var localizer = Context.Services.GetRequiredService<IStringLocalizer<Foo>>();
var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb =>
{
pb.AddChildContent<Table<Foo>>(pb =>
{
pb.Add(a => a.RenderMode, TableRenderMode.Table);
pb.Add(a => a.PageItemsSource, new int[] { 2, 4, 8 });
pb.Add(a => a.IsPagination, true);
pb.Add(a => a.OnQueryAsync, OnQueryAsync(localizer));
pb.Add(a => a.TableColumns, foo => builder =>
{
builder.OpenComponent<TableColumn<Foo, string>>(0);
builder.AddAttribute(1, "Field", "Name");
builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Name", typeof(string)));
builder.CloseComponent();
});
});
});
var pager = cut.FindComponent<Pagination>();
await cut.InvokeAsync(() => pager.Instance.OnPageItemsChanged!.Invoke(2));
var activePage = cut.Find(".page-item.active");
Assert.Equal("1", activePage.TextContent);
await cut.InvokeAsync(() => pager.Instance.OnPageClick!.Invoke(2, 2));
activePage = cut.Find(".page-item.active");
Assert.Equal("2", activePage.TextContent);
}
[Fact] [Fact]
public void IsFixedHeader_Ok() public void IsFixedHeader_Ok()
{ {