Skip to content

Commit 147d379

Browse files
committed
test: 更新单元测试
1 parent f4ad666 commit 147d379

File tree

2 files changed

+19
-26
lines changed

2 files changed

+19
-26
lines changed

test/UnitTest/Components/EditorFormTest.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -276,32 +276,6 @@ public void EditorItem_Ok()
276276
});
277277
}
278278

279-
[Fact]
280-
public void LabelWidth_Ok()
281-
{
282-
var foo = new Foo();
283-
var cut = Context.RenderComponent<ValidateForm>(pb =>
284-
{
285-
pb.Add(a => a.Model, foo);
286-
pb.Add(a => a.LabelWidth, 120);
287-
pb.AddChildContent<EditorForm<Foo>>(pb =>
288-
{
289-
pb.Add(a => a.AutoGenerateAllItem, false);
290-
pb.Add(a => a.FieldItems, f => builder =>
291-
{
292-
var index = 0;
293-
builder.OpenComponent<EditorItem<Foo, string>>(index++);
294-
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.Field), f.Name);
295-
builder.AddAttribute(index++, nameof(EditorItem<Foo, string>.FieldExpression), Utility.GenerateValueExpression(foo, nameof(Foo.Name), typeof(string)));
296-
builder.CloseComponent();
297-
});
298-
});
299-
});
300-
301-
// EditorForm 使用 ValidatForm 级联参数值
302-
cut.Contains("class=\"row g-3\" style=\"--bb-row-label-width: 120px;\"");
303-
}
304-
305279
[Theory]
306280
[InlineData(true)]
307281
[InlineData(false)]

test/UnitTest/Components/ValidateFormTest.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,25 @@ public void ShowLabel_Ok()
162162
cut.DoesNotContain("label");
163163
}
164164

165+
[Fact]
166+
public void LabelWidth_Ok()
167+
{
168+
var foo = new Foo();
169+
var cut = Context.RenderComponent<ValidateForm>(pb =>
170+
{
171+
pb.Add(a => a.Model, foo);
172+
pb.Add(a => a.LabelWidth, 120);
173+
pb.AddChildContent<BootstrapInput<string>>(pb =>
174+
{
175+
pb.Add(a => a.Value, foo.Name);
176+
pb.Add(a => a.ValueChanged, EventCallback.Factory.Create<string?>(this, v => foo.Name = v));
177+
pb.Add(a => a.ValueExpression, foo.GenerateValueExpression());
178+
});
179+
});
180+
181+
cut.Contains("style=\"--bb-row-label-width: 120px;\"");
182+
}
183+
165184
[Fact]
166185
public async Task SetError_Ok()
167186
{

0 commit comments

Comments
 (0)