From b3c2b768947949e76e37d5cebf0f6be7e25d8693 Mon Sep 17 00:00:00 2001 From: Dmitry Filatov Date: Fri, 21 Jul 2017 00:10:02 +0300 Subject: [PATCH] Fix specs for functional components --- .../functionComponent.spec.js | 18 +++++++++++------- spec/renderToDom/renderToDom.spec.js | 4 ++-- spec/renderToString/renderToString.spec.js | 6 +++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/spec/functionComponent/functionComponent.spec.js b/spec/functionComponent/functionComponent.spec.js index 9a07b3f..d897d9f 100644 --- a/spec/functionComponent/functionComponent.spec.js +++ b/spec/functionComponent/functionComponent.spec.js @@ -14,20 +14,24 @@ describe('functionComponent', () => { }); it('should pass empty object as attrs if they aren\'t specified', () => { - const spy = sinon.spy(); + const stub = sinon.stub(); - mountSync(domNode, node(spy)); + stub.returns(null); - expect(spy.args[0][0]).to.be.equal(emptyObj); + mountSync(domNode, node(stub)); + + expect(stub.args[0][0]).to.be.equal(emptyObj); }); it('should merge passed with default attributes', () => { - const spy = sinon.spy(); + const stub = sinon.stub(); + + stub.returns(null); - spy.defaultAttrs = { a : 1, b : 2 }; + stub.defaultAttrs = { a : 1, b : 2 }; - mountSync(domNode, node(spy).setAttrs({ a : 3 })); + mountSync(domNode, node(stub).setAttrs({ a : 3 })); - expect(spy.args[0][0]).to.be.eql({ a : 3, b : 2 }); + expect(stub.args[0][0]).to.be.eql({ a : 3, b : 2 }); }); }); diff --git a/spec/renderToDom/renderToDom.spec.js b/spec/renderToDom/renderToDom.spec.js index ce8ddbe..5282772 100644 --- a/spec/renderToDom/renderToDom.spec.js +++ b/spec/renderToDom/renderToDom.spec.js @@ -306,8 +306,8 @@ describe('renderToDom', () => { expect(domNode.firstChild.firstChild.namespaceURI).to.equal('http://www.w3.org/2000/svg'); }); - it('should render comment if onRender() returns nothing', () => { - const Component = () => {}, + it('should render comment if onRender() returns null', () => { + const Component = () => null, domNode = (topNode = node(Component)).renderToDom(null); expect(domNode.nodeType).to.equal(Node.COMMENT_NODE); diff --git a/spec/renderToString/renderToString.spec.js b/spec/renderToString/renderToString.spec.js index 162a68a..7efe83c 100644 --- a/spec/renderToString/renderToString.spec.js +++ b/spec/renderToString/renderToString.spec.js @@ -192,7 +192,7 @@ describe('renderToString', () => { describe('component', () => { it('should be rendered as component', () => { const Component = createComponent({ - onRender : function() { + onRender() { return createNode('div').setAttrs(this.attrs).setChildren([ createNode('a'), createNode('span') @@ -229,8 +229,8 @@ describe('renderToString', () => { .to.equal('
'); }); - it('should render comment if returns nothing', () => { - const Component = () => {}; + it('should render comment if returns null', () => { + const Component = () => null; expect(createNode(Component).renderToString()) .to.equal('');