Skip to content

Commit 5a8fa9e

Browse files
committed
refactor(CardUpload): Update unit test
1 parent 747c448 commit 5a8fa9e

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/BootstrapBlazor/Components/Upload/CardUpload.razor

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@
2929
<FileIcon Extension="@item.GetExtension()"></FileIcon>
3030
}
3131
</div>
32-
<div class="upload-item-size"><span>@item.GetFileName()</span> @($"{(ShowFileSize ? $"({item.Size.ToFileSizeString()})" : "")}")</div>
32+
<div class="upload-item-size">
33+
<span>@item.GetFileName()</span>
34+
@if (ShowFileSize)
35+
{
36+
<span class="file-size-view">(@item.Size.ToFileSizeString())</span>
37+
}
38+
</div>
3339
<div class="upload-item-actions">
3440
<div class="btn-group">
3541
@if (BeforeActionButtonTemplate != null)

test/UnitTest/Components/UploadCardTest.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public async Task CardUpload_Ok()
1818
{
1919
pb.Add(a => a.ShowZoomButton, true);
2020
pb.Add(a => a.ShowDeleteButton, true);
21-
pb.Add(a => a.ShowFileSize, false);
21+
pb.Add(a => a.ShowFileSize, true);
2222
pb.Add(a => a.OnDelete, file =>
2323
{
2424
deleted = true;
@@ -36,6 +36,7 @@ public async Task CardUpload_Ok()
3636
new() { FileName = null! }
3737
]);
3838
});
39+
cut.Contains("file-size-view");
3940
cut.Contains("bb-previewer collapse active");
4041
cut.Contains("aria-label=\"zoom\"");
4142
cut.Contains("aria-label=\"delete\"");
@@ -124,9 +125,11 @@ await cut.InvokeAsync(() => input.Instance.OnChange.InvokeAsync(new InputFileCha
124125
{
125126
pb.Add(a => a.IsUploadButtonAtFirst, true);
126127
pb.Add(a => a.IsMultiple, true);
128+
pb.Add(a => a.ShowFileSize, false);
127129
pb.Add(a => a.ShowZoomButton, false);
128130
pb.Add(a => a.ShowDeleteButton, false);
129131
});
132+
cut.DoesNotContain("file-size-view");
130133
cut.DoesNotContain("aria-label=\"zoom\"");
131134
cut.DoesNotContain("aria-label=\"delete\"");
132135
}

0 commit comments

Comments
 (0)