Skip to content

Commit ed87d9a

Browse files
committed
Add test for nested arrays
1 parent 7a2b497 commit ed87d9a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/react/rails/component_mount_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,5 +197,22 @@ def self.react_rails_prerenderer
197197

198198
assert_equal(expected_json, actual_json)
199199
end
200+
201+
test "#props_to_json doesnt converts null values in nested arrays to undefined with null_to_undefined: true" do
202+
props = {
203+
items1: nil,
204+
items2: [1, nil, 2],
205+
items3: nil,
206+
items4: "[1, null, 2]",
207+
items5: nil
208+
}
209+
expected_json = '{"items1":undefined,"items2":[1,undefined,2],"items3":undefined,"items4":"[1, null, 2]"' \
210+
',"items5":undefined}'
211+
component_mount = React::Rails::ComponentMount.new
212+
213+
actual_json = component_mount.send(:props_to_json, props, { null_to_undefined: true })
214+
215+
assert_equal(expected_json, actual_json)
216+
end
200217
end
201218
end

0 commit comments

Comments
 (0)