From 4bd4a5776965b548b67f5e474c205afd71635291 Mon Sep 17 00:00:00 2001 From: hunterbmt Date: Wed, 1 Jun 2016 14:36:28 +0700 Subject: [PATCH] Wrapping all new context test into describeIf() --- test/staticRender-spec.jsx | 60 +++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/test/staticRender-spec.jsx b/test/staticRender-spec.jsx index 92381f12f..564cf7e33 100644 --- a/test/staticRender-spec.jsx +++ b/test/staticRender-spec.jsx @@ -24,38 +24,38 @@ describeWithDOM('render', () => { const wrapper = render(, { context }); expect(wrapper.text()).to.equal('foo'); }); - }); - it('can pass context to the child of mounted component', () => { - const SimpleComponent = React.createClass({ - contextTypes: { - name: React.PropTypes.string, - }, - render() { - return
{this.context.name}
; - }, - }); - const ComplexComponent = React.createClass({ - render() { - return
; - }, - }); + it('can pass context to the child of mounted component', () => { + const SimpleComponent = React.createClass({ + contextTypes: { + name: React.PropTypes.string, + }, + render() { + return
{this.context.name}
; + }, + }); + const ComplexComponent = React.createClass({ + render() { + return
; + }, + }); - const childContextTypes = { - name: React.PropTypes.string.isRequired, - }; - const context = { name: 'foo' }; - const wrapper = render(, { context, childContextTypes }); - expect(wrapper.children()).to.have.length(1); - expect(wrapper.children().first().text()).to.equal('foo'); - }); - it('should not throw if context is passed in but contextTypes is missing', () => { - const SimpleComponent = React.createClass({ - render() { - return
{this.context.name}
; - }, + const childContextTypes = { + name: React.PropTypes.string.isRequired, + }; + const context = { name: 'foo' }; + const wrapper = render(, { context, childContextTypes }); + expect(wrapper.children()).to.have.length(1); + expect(wrapper.children().first().text()).to.equal('foo'); }); + it('should not throw if context is passed in but contextTypes is missing', () => { + const SimpleComponent = React.createClass({ + render() { + return
{this.context.name}
; + }, + }); - const context = { name: 'foo' }; - expect(() => render(, { context })).to.not.throw(Error); + const context = { name: 'foo' }; + expect(() => render(, { context })).to.not.throw(Error); + }); }); });