Skip to content

Commit 7997234

Browse files
Add test for TransformRenderedHtml
1 parent 1a3372d commit 7997234

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tests/React.Tests/Core/ReactComponentTest.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public void RenderFunctionsCalled()
339339
{
340340
var environment = new Mock<IReactEnvironment>();
341341
environment.Setup(x => x.Execute<bool>("typeof Foo !== 'undefined'")).Returns(true);
342-
environment.Setup(x => x.Execute<string>(@"ReactDOMServer.renderToString(wrap(React.createElement(Foo, {""hello"":""World""})))"))
342+
environment.Setup(x => x.Execute<string>(@"outerWrap(ReactDOMServer.renderToString(wrap(React.createElement(Foo, {""hello"":""World""}))))"))
343343
.Returns("[HTML]");
344344

345345
environment.Setup(x => x.Execute<string>(@"prerender();"))
@@ -375,8 +375,11 @@ public void ChainedRenderFunctionsCalled()
375375
Assert.Equal("prerender-result", renderFunctions.PreRenderResult);
376376
Assert.Equal("prerender-result", chainedRenderFunctions.PreRenderResult);
377377

378-
string transformed = chainedRenderFunctions.WrapComponent("React.createElement('div', null)");
379-
Assert.Equal("wrap(wrap(React.createElement('div', null)))", transformed);
378+
string wrapComponentResult = chainedRenderFunctions.WrapComponent("React.createElement('div', null)");
379+
Assert.Equal("wrap(wrap(React.createElement('div', null)))", wrapComponentResult);
380+
381+
Assert.Equal("outerWrap(input)", renderFunctions.TransformRenderedHtml("input"));
382+
Assert.Equal("outerWrap(outerWrap(input))", chainedRenderFunctions.TransformRenderedHtml("input"));
380383

381384
chainedRenderFunctions.PostRender(a => "postrender-result");
382385

@@ -404,6 +407,11 @@ protected override string WrapComponentCore(string componentToRender)
404407
return $"wrap({componentToRender})";
405408
}
406409

410+
protected override string TransformRenderedHtmlCore(string input)
411+
{
412+
return $"outerWrap({input})";
413+
}
414+
407415
protected override void PostRenderCore(Func<string, string> executeJs)
408416
{
409417
PostRenderResult = executeJs("postrender();");

0 commit comments

Comments
 (0)