Skip to content

Commit

Permalink
Fix specs for functional components
Browse files Browse the repository at this point in the history
  • Loading branch information
dfilatov committed Jul 20, 2017
1 parent 074135f commit b3c2b76
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
18 changes: 11 additions & 7 deletions spec/functionComponent/functionComponent.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
});
4 changes: 2 additions & 2 deletions spec/renderToDom/renderToDom.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions spec/renderToString/renderToString.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -229,8 +229,8 @@ describe('renderToString', () => {
.to.equal('<div id="id1"><a></a><span></span><i></i></div>');
});

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('<!---->');
Expand Down

0 comments on commit b3c2b76

Please sign in to comment.