diff --git a/fixtures/this.jsx b/fixtures/this.jsx new file mode 100644 index 0000000..9301d05 --- /dev/null +++ b/fixtures/this.jsx @@ -0,0 +1 @@ +
{this.props.name}
diff --git a/test.js b/test.js index 7ca54e8..3097ed8 100644 --- a/test.js +++ b/test.js @@ -29,7 +29,7 @@ describe('react-jsx', function () { var Hello = React.createClass({ render: function render() { - return jsx.server(fixtures.hello, { render: 'DOM' })(this); + return jsx.server(fixtures.hello)(this); } }); @@ -61,6 +61,12 @@ describe('react-jsx', function () { assume(client).is.a('function'); assume(React.isValidElement(client({ defaultValue: 1 }))).is.true(); }); + + it('can also output HTML', function () { + var client = jsx.client(fixtures.react, { raw: true }); + + assume(client({}, { html: true })).equals('
content
'); + }); }); describe('.server', function () { @@ -119,5 +125,27 @@ describe('react-jsx', function () { assume(result).equals('
Hello john
'); }); + + it('assumes data should be used as this if it has props', function () { + var server = jsx.server('', { raw: true }) + , that = jsx.server(fixtures.this); + + var Hello = React.createClass({ + render: function () { + return that(this); + } + }); + + assume(server).is.a('function'); + assume(server({ Hello: Hello }, { html: true })).equals('
lol
'); + }); + + it('works with a custom `this`', function () { + var that = jsx.server(fixtures.this, { raw: true }); + + assume(that.call({ + props: { name: 'john' } + }, {}, { html: true })).equals('
john
'); + }); }); });