Skip to content

Commit

Permalink
Broken test for metal#345
Browse files Browse the repository at this point in the history
  • Loading branch information
Kien Do committed Jan 24, 2018
1 parent 6a74b18 commit 9587189
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions packages/metal-jsx/test/JSXComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,55 @@ describe('JSXComponent', function() {
assert.ok(dom.hasClass(component.element, 'parent'));
assert.ok(dom.hasClass(component.element, 'grandchild'));
});

it('should use default prop value when "undefined" is passed as a value on update', function(
done
) {
class ChildComponent extends JSXComponent {
render() {
return <div />;
}
}
ChildComponent.PROPS = {
childFoo: {
value: 'foo',
},
childBar: {
value: 'bar',
},
};

class ParentComponent extends JSXComponent {
render() {
return (
<ChildComponent
childBar={this.state.bar}
childFoo={this.state.foo}
ref="childComponent"
/>
);
}
}
ParentComponent.STATE = {
bar: {
value: 'bar',
},
foo: {},
};

component = new ParentComponent();

component.state.bar = 'newBar';

component.once('stateChanged', function() {
assert.strictEqual(
component.refs.childComponent.props.childBar,
'newBar'
);
assert.strictEqual(component.refs.childComponent.props.childFoo, 'foo');
done();
});
});
});

describe('shouldUpdate', function() {
Expand Down

0 comments on commit 9587189

Please sign in to comment.