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

Commit d367169

Browse files
committed
update tests
1 parent dc08d65 commit d367169

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/view_helper_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,29 @@ class ViewHelperTest < ActionDispatch::IntegrationTest
4848
assert html.include?('class="test"')
4949
assert html.include?('data-foo="1"')
5050
end
51+
52+
test 'ujs object present on the global React object and has our methods' do
53+
visit '/pages/1'
54+
assert page.has_content?('Hello Bob')
55+
56+
# the exposed ujs object is present
57+
ujs_present = page.evaluate_script('typeof React.ujs === "object";')
58+
assert_equal(ujs_present, true)
59+
60+
# it contains the constants
61+
class_name_present = page.evaluate_script('React.ujs.CLASS_NAME_ATTR === "data-react-class";')
62+
assert_equal(class_name_present, true)
63+
props_present = page.evaluate_script('React.ujs.PROPS_ATTR === "data-react-props";')
64+
assert_equal(props_present, true)
65+
66+
#it contains the methods
67+
find_dom_nodes_present = page.evaluate_script('typeof React.ujs.findDOMNodes === "function";')
68+
assert_equal(find_dom_nodes_present, true)
69+
mount_components_present = page.evaluate_script('typeof React.ujs.mountComponents === "function";')
70+
assert_equal(mount_components_present, true)
71+
unmount_components_present = page.evaluate_script('typeof React.ujs.unmountComponents === "function";')
72+
assert_equal(unmount_components_present, true)
73+
end
5174

5275
test 'react_ujs works with rendered HTML' do
5376
visit '/pages/1'

0 commit comments

Comments
 (0)