Skip to content

Commit 44897ff

Browse files
committed
test: 增加单元测试
1 parent 1387d8e commit 44897ff

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

test/UnitTest/Components/SearchTest.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,20 @@ public void PrefixIconTemplate_Ok()
169169
var cut = Context.RenderComponent<Search<string?>>(pb =>
170170
{
171171
pb.Add(a => a.ShowPrefixIcon, true);
172-
pb.Add(a => a.PrefixIconTemplate, b => b.AddContent(0, "test-prefix-icon-template"));
172+
pb.Add(a => a.PrefixIconTemplate, context => b => b.AddContent(0, "test-prefix-icon-template"));
173173
});
174-
cut.Contains("<div class=\"search-icon search-prefix-icon\">test-prefix-icon-template</div>");
174+
cut.Contains("<div class=\"search-prefix-icon\">test-prefix-icon-template</div>");
175+
}
176+
177+
[Fact]
178+
public void IconTemplate_Ok()
179+
{
180+
var items = new List<string?>() { null, "test1", "test2" };
181+
var cut = Context.RenderComponent<Search<string?>>(pb =>
182+
{
183+
pb.Add(a => a.IconTemplate, context => b => b.AddContent(0, "test--icon-template"));
184+
});
185+
cut.Contains("<div class=\"search-icon\">test-icon-template</div>");
175186
}
176187

177188
[Fact]
@@ -201,13 +212,13 @@ public void ButtonTemplate_Ok()
201212
{
202213
var cut = Context.RenderComponent<Search<string?>>(pb =>
203214
{
204-
pb.Add(a => a.ButtonTemplate, builder => builder.AddContent(0, "button-template"));
215+
pb.Add(a => a.ButtonTemplate, context => builder => builder.AddContent(0, "button-template"));
205216
});
206217
cut.Contains("button-template");
207218

208219
cut.SetParametersAndRender(pb =>
209220
{
210-
pb.Add(a => a.PrefixButtonTemplate, builder => builder.AddContent(0, "prefix-button-template"));
221+
pb.Add(a => a.PrefixButtonTemplate, context => builder => builder.AddContent(0, "prefix-button-template"));
211222
});
212223
cut.Contains("prefix-button-template");
213224
}

0 commit comments

Comments
 (0)