# -*- coding: utf-8 -*-
import dukpy


class TestReactJS(object):
    def test_hello_world(self):
        jsx = dukpy.jsx_compile('var react_hello = <h1>Hello, world!</h1>;')
        jsi = dukpy.JSInterpreter()
        result = jsi.evaljs([
            '''
            var React = require('react/react'),
             ReactDOM = require('react/react-dom-server');
            ''',
            jsx,
            'ReactDOM.renderToStaticMarkup(react_hello, null);'
        ])
        assert result == '<h1>Hello, world!</h1>'

@@ -515,9 +515,903 @@
 d!%3C/h1%3E'
-%0A
+, res%0A%0A    def test_jsx_mixed(self):%0A        code = '''%0Avar React = require('react/react'),%0A ReactDOM = require('react/react-dom-server');%0AReactDOM.renderToStaticMarkup(%3Ch1%3EHello, world!%3C/h1%3E, null);%0A'''%0A        jsx = dukpy.jsx_compile(code)%0A        res = dukpy.evaljs(jsx)%0A        assert res == '%3Ch1%3EHello, world!%3C/h1%3E', res%0A%0A    def test_react_binding(self):%0A        code = '''%0Avar React = require('react/react'),%0A ReactDOM = require('react/react-dom-server');%0A%0Avar HelloWorld = React.createClass(%7B%0A  render: function() %7B%0A    return (%0A      %3Cdiv className=%22helloworld%22%3E%0A        Hello %7Bthis.props.data.name%7D%0A      %3C/div%3E%0A    );%0A  %7D%0A%7D);%0A%0AReactDOM.renderToStaticMarkup(%3CHelloWorld data=%7Bdukpy.data%7D/%3E, null);%0A'''%0A        jsx = dukpy.jsx_compile(code)%0A        res = dukpy.evaljs(jsx, data=%7B'id': 1, 'name': %22Alessandro%22%7D)%0A        assert res == '%3Cdiv class=%22helloworld%22%3EHello Alessandro%3C/div%3E', res

Add tests for a React Component