Fix issue with blog preview when content under 1000 chars.
This commit is contained in:
parent
3a8aedd653
commit
0f64014b30
6 changed files with 38 additions and 10 deletions
31
Website.Tests/VIewModels/BlogPostPreviewViewModelTests.cs
Normal file
31
Website.Tests/VIewModels/BlogPostPreviewViewModelTests.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using FluentAssertions;
|
||||
using Website.Data.States;
|
||||
using Website.Models;
|
||||
using Website.ViewModels;
|
||||
using Xunit;
|
||||
|
||||
namespace Website.Tests.VIewModels
|
||||
{
|
||||
public class BlogPostPreviewViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
public void Constructor_WithContentOver1000Characters_LimitsContentTo1000Chars() {
|
||||
var state = new BlogPostState {
|
||||
Post_Content = new string('a', 1001)
|
||||
};
|
||||
var post = new BlogPost(state);
|
||||
var vm = new BlogPostPreviewViewModel(post);
|
||||
vm.Content.Length.Should().Be(1000);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WithContentUnder1000Characters_ContentIsIdenticalLength() {
|
||||
var state = new BlogPostState {
|
||||
Post_Content = new string('a', 900)
|
||||
};
|
||||
var post = new BlogPost(state);
|
||||
var vm = new BlogPostPreviewViewModel(post);
|
||||
vm.Content.Length.Should().Be(900);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,13 +10,13 @@ namespace Website.Tests.VIewModels
|
|||
public class BlogPostViewModelTests
|
||||
{
|
||||
[Fact]
|
||||
public void Content_WithMarkdownContent_ReturnsHtml() {
|
||||
public void ContentHtml_WithMarkdownContent_ReturnsHtml() {
|
||||
var state = new BlogPostState {
|
||||
Post_Content="# header"
|
||||
};
|
||||
var post = new BlogPost(state);
|
||||
var vm = new BlogPostViewModel(post);
|
||||
vm.Content.Should().Be("<h1>header</h1>");
|
||||
vm.ContentHtml.Should().Be("<h1>header</h1>");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue