Skip to content

Commit

Permalink
Added Test for oninput for create new blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Oct 23, 2021
1 parent bd2ddb3 commit 741417e
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,31 @@ public void ShouldNotSetOptionToNotUpdateUpdatedDateOnInitialCreate()

found.Should().HaveCount(0);
}

[Fact]
public void ShouldAcceptInputWithoutLosingFocusOrEnter()
{
BlogPost blogPost = null;
var cut = RenderComponent<CreateNewBlogPost>(
p => p.Add(c => c.OnBlogPostCreated, bp => blogPost = bp));
cut.Find("#title").Input("My Title");
cut.Find("#short").Input("My short Description");
cut.Find("#content").Input("My content");
cut.Find("#preview").Change("My preview url");
cut.Find("#published").Change(false);
cut.Find("#tags").Change("Tag1,Tag2,Tag3");

cut.Find("form").Submit();

cut.WaitForState(() => cut.Find("#title").TextContent == string.Empty);
blogPost.Should().NotBeNull();
blogPost.Title.Should().Be("My Title");
blogPost.ShortDescription.Should().Be("My short Description");
blogPost.Content.Should().Be("My content");
blogPost.PreviewImageUrl.Should().Be("My preview url");
blogPost.IsPublished.Should().BeFalse();
blogPost.Tags.Should().HaveCount(3);
blogPost.Tags.Select(t => t.Content).Should().Contain(new[] { "Tag1", "Tag2", "Tag3" });
}
}
}

0 comments on commit 741417e

Please sign in to comment.