Skip to content

Commit 5e76a6c

Browse files
committed
Add extra test. Brings back code coverage to 100% for Row and Cell
1 parent f928a1c commit 5e76a6c

File tree

1 file changed

+48
-22
lines changed

1 file changed

+48
-22
lines changed

tests/Core/Components/DataGrid/FluentDataGridRowTests.razor

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,28 @@
4141
Assert.NotNull(row.Instance.ChildContent);
4242
}
4343

44+
[Fact]
45+
public void FluentDataGridRow_Columns()
46+
{
47+
// Arrange
48+
var grid = Render<FluentDataGrid<object>>(
49+
@<FluentDataGrid TGridItem="object" GenerateHeader="DataGridGeneratedHeaderType.None">
50+
<FluentDataGridRow>
51+
<FluentDataGridCell />
52+
</FluentDataGridRow>
53+
</FluentDataGrid>
54+
);
55+
56+
// Act
57+
var row = grid.FindComponent<FluentDataGridRow<object>>();
58+
59+
// Assert
60+
Assert.NotNull(grid);
61+
Assert.NotNull(row);
62+
63+
Assert.NotNull(row.Instance.Columns);
64+
}
65+
4466
[Fact]
4567
public void FluentDataGridRow_Properties_CompileCorrectly()
4668
{
@@ -238,40 +260,44 @@
238260
<FluentDataGridRow>
239261
<FluentDataGridCell />
240262
</FluentDataGridRow>
241-
</FluentDataGrid>);
263+
</FluentDataGrid>
264+
);
242265

243-
// Act
244-
var cell = cut.FindComponent<FluentDataGridRow<object>>();
245-
await cell.Instance.HandleOnRowFocusAsync();
246-
// Assert
247-
Assert.True(rowFocusInvoked);
248-
}
266+
// Act
267+
var cell = cut.FindComponent<FluentDataGridRow<object>>();
268+
await cell.Instance.HandleOnRowFocusAsync();
269+
// Assert
270+
Assert.True(rowFocusInvoked);
271+
}
249272

250-
[Fact]
251-
public async Task FluentDataGridRow_HandleOnRowKeyDownAsync_HandlesKeyEnter()
252-
{
253-
// Arrange
254-
var items = new List<Person>(People).AsQueryable();
255-
var rowKeyDownInvoked = false;
273+
[Fact]
274+
public async Task FluentDataGridRow_HandleOnRowKeyDownAsync_HandlesKeyEnter()
275+
{
276+
// Arrange
277+
var items = new List<Person>(People).AsQueryable();
278+
var rowKeyDownInvoked = false;
279+
bool click = false;
256280

257281
var cut = Render<FluentDataGrid<Person>>(
258-
@<FluentDataGrid TGridItem="Person" Items="@People" GenerateHeader="DataGridGeneratedHeaderType.None">
282+
@<FluentDataGrid TGridItem="Person" Items="@People" GenerateHeader="DataGridGeneratedHeaderType.None" OnRowClick="()=>{click=true;}">
259283
<SelectColumn TGridItem="Person"
260284
SelectMode="DataGridSelectMode.Multiple"
261285
Selectable="@(x => x.PersonId > 0)"
262286
SelectFromEntireRow="true"
263287
OnSelect="@(e => rowKeyDownInvoked = true)" />
264288
<PropertyColumn Property="@(x => x)" Title="Value" />
265-
</FluentDataGrid>);
289+
</FluentDataGrid>
290+
);
266291

267-
// Act
268-
var keyboardEvent = new KeyboardEventArgs { Code = "Enter" };
269-
var row = cut.FindComponent<FluentDataGridRow<Person>>();
270-
await row.Instance.HandleOnRowKeyDownAsync(row.Instance.RowId, keyboardEvent);
292+
// Act
293+
var keyboardEvent = new KeyboardEventArgs { Code = "Enter" };
294+
var row = cut.FindComponent<FluentDataGridRow<Person>>();
295+
await row.Instance.HandleOnRowKeyDownAsync(row.Instance.RowId, keyboardEvent);
271296

272-
// Assert
273-
Assert.True(rowKeyDownInvoked);
274-
}
297+
// Assert
298+
Assert.True(rowKeyDownInvoked);
299+
Assert.True(click);
300+
}
275301

276302

277303
[Fact]

0 commit comments

Comments
 (0)