From 7393ba3ce5eead45dedbe28acb7e4863e67e62f1 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 29 Aug 2017 16:07:39 -0700 Subject: [PATCH] [Tests] add more render tests --- .../test/staticRender-spec.jsx | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/enzyme-test-suite/test/staticRender-spec.jsx b/packages/enzyme-test-suite/test/staticRender-spec.jsx index 33b05129e..57f23b5f4 100644 --- a/packages/enzyme-test-suite/test/staticRender-spec.jsx +++ b/packages/enzyme-test-suite/test/staticRender-spec.jsx @@ -21,15 +21,25 @@ describeWithDOM('render', () => { const context = { name: 'foo' }; const wrapper = render(, { context }); + + const rootEls = wrapper.children(); + expect(rootEls).to.have.lengthOf(1); + + expect(rootEls.is('div')).to.equal(true); + expect(rootEls.text()).to.equal('foo'); expect(wrapper.text()).to.equal('foo'); + + expect(String(wrapper)).to.equal('
foo
'); + expect(String(rootEls)).to.equal('
foo
'); }); + it('can pass context to the child of mounted component', () => { const SimpleComponent = createClass({ contextTypes: { name: PropTypes.string, }, render() { - return
{this.context.name}
; + return {this.context.name}; }, }); const ComplexComponent = createClass({ @@ -43,9 +53,23 @@ describeWithDOM('render', () => { }; const context = { name: 'foo' }; const wrapper = render(, { context, childContextTypes }); - expect(wrapper.children()).to.have.length(1); - expect(wrapper.children().first().text()).to.equal('foo'); + + const rootEls = wrapper.children(); + expect(rootEls).to.have.length(1); + + expect(rootEls.is('div')).to.equal(true); + + const children = rootEls.children(); + expect(children).to.have.length(1); + expect(children.is('span')).to.equal(true); + + expect(children.first().text()).to.equal('foo'); + + expect(String(wrapper)).to.equal('
foo
'); + expect(String(rootEls)).to.equal('
foo
'); + expect(String(children)).to.equal('foo'); }); + it('should not throw if context is passed in but contextTypes is missing', () => { const SimpleComponent = createClass({ render() {