public void ComponentWithOneElement_CreatesCorrectElementTree() { var component = UIComponentDefinition.Create("Test", converter.Convert(@" function render(props) return ( <Text textAnchor={""MiddleCenter""} alignByGeometry={""false""} text={props.test} /> ) end")); var rootElement = Element.Create(component, new PropCollection(new Dictionary <string, object>() { { "test", "some text" } })); rootElement.Render(); Assert.AreEqual(1, rootElement.Children.Count); Assert.AreEqual("TextComponent", rootElement.Children.First().Component.Name); Assert.AreEqual("MiddleCenter", rootElement.Children.First().Props["textAnchor"]); Assert.AreEqual("false", rootElement.Children.First().Props["alignByGeometry"]); Assert.AreEqual("some text", rootElement.Children.First().Props["text"]); }
public void TemplateWithOneComponentSelfTerminating() { var original = @" function render() return <something /> end"; var expected = @" function render() return Create(""something"") end"; Assert.AreEqual(expected, converter.Convert(original)); }
public UIComponentDefinition Interpret(string source, string pathToFile) { var markup = converter.Convert(source); var component = ScriptableObject.CreateInstance <UIComponentDefinition>(); component.ComponentName = Path.GetFileName(pathToFile)?.Replace(".luax", ""); component.Markup = markup; return(component); }