Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit 1933a3a

Browse files
catmandozetachang
authored andcommitted
added test spec to make sure nested native libraries work
1 parent 807efce commit 1933a3a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

spec/react/native_library_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,26 @@ class NestedComponent < React::Component::Base
6565
React.create_element(Foo::NativeComponent, name: "There"))).to eq('<div>Hello There</div>')
6666
end
6767

68+
it "will import a nested React.js library into the Ruby name space" do
69+
%x{
70+
window.NativeLibrary = {
71+
NestedLibrary: {
72+
NativeComponent: React.createClass({
73+
displayName: "HelloMessage",
74+
render: function render() {
75+
return React.createElement("div", null, "Hello ", this.props.name);
76+
}
77+
})}
78+
}
79+
}
80+
stub_const 'Foo', Class.new(React::NativeLibrary)
81+
Foo.class_eval do
82+
imports "NativeLibrary"
83+
end
84+
expect(React.render_to_static_markup(
85+
React.create_element(Foo::NestedLibrary::NativeComponent, name: "There"))).to eq('<div>Hello There</div>')
86+
end
87+
6888
it "will rename an imported a React.js component" do
6989
%x{
7090
window.NativeLibrary = {

0 commit comments

Comments
 (0)