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 4a99eba
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 @@ -676,5 +676,54 @@ describe('JSXComponent', function() {

assert.deepEqual(component.otherProps(), {});
});

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();
});
});
});
});

0 comments on commit 4a99eba

Please sign in to comment.