|
2 | 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
3 | 3 | // Website: https://www.blazor.zone or https://argozhang.github.io/ |
4 | 4 |
|
| 5 | +using AngleSharp.Dom; |
5 | 6 | using BootstrapBlazor.Shared; |
6 | 7 | using Microsoft.AspNetCore.Components.Forms; |
7 | 8 | using Microsoft.AspNetCore.Components.Web; |
@@ -1514,6 +1515,54 @@ public void TableFooter_Ok(TableRenderMode mode) |
1514 | 1515 | cut.Contains("table-footer-test"); |
1515 | 1516 | } |
1516 | 1517 |
|
| 1518 | + [Fact] |
| 1519 | + public void IsHideFooterWhenNoData_Ok() |
| 1520 | + { |
| 1521 | + var localizer = Context.Services.GetRequiredService<IStringLocalizer<Foo>>(); |
| 1522 | + var cut = Context.RenderComponent<BootstrapBlazorRoot>(pb => |
| 1523 | + { |
| 1524 | + pb.AddChildContent<Table<Foo>>(pb => |
| 1525 | + { |
| 1526 | + pb.Add(a => a.RenderMode, TableRenderMode.Table); |
| 1527 | + pb.Add(a => a.ShowFooter, true); |
| 1528 | + pb.Add(a => a.IsHideFooterWhenNoData, false); |
| 1529 | + pb.Add(a => a.Items, Foo.GenerateFoo(localizer)); |
| 1530 | + pb.Add(a => a.TableColumns, foo => builder => |
| 1531 | + { |
| 1532 | + builder.OpenComponent<TableColumn<Foo, string>>(0); |
| 1533 | + builder.AddAttribute(1, "Field", "Name"); |
| 1534 | + builder.AddAttribute(2, "FieldExpression", Utility.GenerateValueExpression(foo, "Name", typeof(string))); |
| 1535 | + builder.CloseComponent(); |
| 1536 | + }); |
| 1537 | + pb.Add(a => a.TableFooter, foos => builder => |
| 1538 | + { |
| 1539 | + builder.AddContent(0, "table-footer-test"); |
| 1540 | + }); |
| 1541 | + }); |
| 1542 | + }); |
| 1543 | + cut.Contains("table-footer-test"); |
| 1544 | + |
| 1545 | + var table = cut.FindComponent<Table<Foo>>(); |
| 1546 | + table.SetParametersAndRender(pb => |
| 1547 | + { |
| 1548 | + pb.Add(a => a.IsHideFooterWhenNoData, false); |
| 1549 | + }); |
| 1550 | + cut.Contains("table-footer-test"); |
| 1551 | + |
| 1552 | + table.SetParametersAndRender(pb => |
| 1553 | + { |
| 1554 | + pb.Add(a => a.Items, null); |
| 1555 | + }); |
| 1556 | + cut.Contains("table-footer-test"); |
| 1557 | + |
| 1558 | + table.SetParametersAndRender(pb => |
| 1559 | + { |
| 1560 | + pb.Add(a => a.Items, null); |
| 1561 | + pb.Add(a => a.IsHideFooterWhenNoData, true); |
| 1562 | + }); |
| 1563 | + cut.DoesNotContain("table-footer-test"); |
| 1564 | + } |
| 1565 | + |
1517 | 1566 | [Fact] |
1518 | 1567 | public void FooterTemplate_Ok() |
1519 | 1568 | { |
|
0 commit comments