File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
src/LinkDotNet.Blog.Web/Features/ShowBlogPost/Components
tests/LinkDotNet.Blog.UnitTests/Web/Features/ShowBlogPost/Components Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 21
21
[Parameter ]
22
22
public string Author { get ; set ; }
23
23
24
- private string StructuredDataJson { get ; set ; }
24
+ private MarkupString StructuredDataJson { get ; set ; }
25
25
26
26
private readonly JsonSerializerOptions jsonOptions = new () { WriteIndented = true };
27
27
43
43
article .Image .Add (PreviewFallbackImage );
44
44
}
45
45
46
- StructuredDataJson = JsonSerializer .Serialize (article , jsonOptions );
46
+ StructuredDataJson = ( MarkupString ) JsonSerializer .Serialize (article , jsonOptions );
47
47
48
48
await base .OnParametersSetAsync ();
49
49
}
Original file line number Diff line number Diff line change
1
+ using LinkDotNet . Blog . Web . Features . ShowBlogPost . Components ;
2
+ using Microsoft . AspNetCore . Components . Web ;
3
+
4
+ namespace LinkDotNet . Blog . UnitTests . Web . Features . ShowBlogPost . Components ;
5
+
6
+ public class StructuredDataTests : TestContext
7
+ {
8
+ [ Fact ]
9
+ public void ShouldRenderRawMarkup ( )
10
+ {
11
+ ComponentFactories . AddStub < HeadContent > ( ps => ps . Get ( p => p . ChildContent ) ) ;
12
+
13
+ var cut = RenderComponent < StructuredData > (
14
+ ps => ps . Add ( p => p . Author , "Steven" )
15
+ . Add ( p => p . Headline , "Headline" )
16
+ . Add ( p => p . PreviewImage , "url1" )
17
+ . Add ( p => p . PreviewFallbackImage , "url2" ) ) ;
18
+
19
+ var element = cut . Find ( "script" ) ;
20
+ element . Should ( ) . NotBeNull ( ) ;
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments