{
+ testProp = this.props.testProp || 'no prop';
+ spreadDemo = { ...this.props };
+ render() {
+ return (
+
+ Hello {this.spreadDemo.name}! Passed in: {this.testProp}
+
+ );
+ }
+}
diff --git a/tests/React.Tests.Integration/ServerRenderTests.cs b/tests/React.Tests.Integration/ServerRenderTests.cs
index 5b4e0f66b..298134fed 100644
--- a/tests/React.Tests.Integration/ServerRenderTests.cs
+++ b/tests/React.Tests.Integration/ServerRenderTests.cs
@@ -1,8 +1,6 @@
using System;
-using System.Linq;
using System.IO;
using System.Text;
-using System.Threading.Tasks;
using JavaScriptEngineSwitcher.ChakraCore;
using JavaScriptEngineSwitcher.Core;
using React.Tests.Common;
@@ -76,12 +74,55 @@ public void RendersPrecompiledScript(bool withPrecompilation)
for (int i = 0; i < 20; i++)
{
var stringWriter = new StringWriter(new StringBuilder(128));
- ReactEnvironment.GetCurrentOrThrow.CreateComponent("HelloWorld", new { name = "Tester" }, serverOnly: true).RenderHtml(stringWriter, renderServerOnly: true);
+ ReactEnvironment.Current.CreateComponent("HelloWorld", new { name = "Tester" }, serverOnly: true).RenderHtml(stringWriter, renderServerOnly: true);
Assert.Equal("Hello Tester!
", stringWriter.ToString());
ReactEnvironment.Current.ReturnEngineToPool();
}
}
+ [Theory]
+ [InlineData(null)]
+ [InlineData("babel-6")]
+ public void BabelTransformsJSX(string babelVersion)
+ {
+ ReactEnvironment.Current.Configuration
+ .SetLoadBabel(true)
+ .SetBabelVersion(babelVersion);
+
+ Assert.Equal(@"React.createElement(
+ ""div"",
+ null,
+ ""Hello""
+);", ReactEnvironment.Current.Babel.Transform("Hello
"));
+ }
+
+ [Fact]
+ public void BabelTransformsTypescript()
+ {
+ ReactEnvironment.Current.Configuration
+ .SetLoadBabel(true)
+ .SetBabelVersion(BabelVersions.Babel7);
+
+ Assert.Equal(@"function render(foo) {
+ return React.createElement(""div"", null, ""Hello "", foo);
+}", ReactEnvironment.Current.Babel.Transform("function render(foo: number) { return (Hello {foo}
) }", "test.tsx"));
+ }
+
+ [Fact]
+ public void RendersTypescript()
+ {
+ ReactEnvironment.Current.Configuration
+ .SetReuseJavaScriptEngines(false)
+ .SetLoadBabel(true)
+ .AddScript("Sample.tsx")
+ .SetBabelVersion(BabelVersions.Babel7);
+
+ var stringWriter = new StringWriter(new StringBuilder(128));
+ ReactEnvironment.Current.CreateComponent("HelloTypescript", new { name = "Tester" }, serverOnly: true).RenderHtml(stringWriter, renderServerOnly: true);
+ Assert.Equal("Hello Tester! Passed in: no prop
", stringWriter.ToString());
+ ReactEnvironment.Current.ReturnEngineToPool();
+ }
+
#if !NET461
[Fact]
public void TestMemoryFileCache()
@@ -103,15 +144,5 @@ public void Dispose()
AssemblyRegistration.Container.Unregister();
AssemblyRegistration.Container.Unregister();
}
-
- [Fact]
- public void BabelTransformsJSX()
- {
- Assert.Equal(@"React.createElement(
- ""div"",
- null,
- ""Hello""
-);", ReactEnvironment.Current.Babel.Transform("Hello
"));
- }
}
}
diff --git a/tutorial-code/Startup.cs b/tutorial-code/Startup.cs
index 853c0b98b..0a8f041aa 100644
--- a/tutorial-code/Startup.cs
+++ b/tutorial-code/Startup.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;