Class: React::Test::Session
Constant Summary collapse
- DSL_METHODS =
%i[mount instance update_params html].freeze
Instance Method Summary collapse
- #html ⇒ Object
- #instance ⇒ Object
- #mount(component_klass, params = {}) ⇒ Object
- #update_params(params, &block) ⇒ Object
Instance Method Details
#html ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/react/test/session.rb', line 25 def html html = `#@container.innerHTML` %x{ var REGEX_REMOVE_ROOT_IDS = /\s?data-reactroot="[^"]*"/g; var REGEX_REMOVE_IDS = /\s?data-reactid="[^"]+"/g; html = html.replace(REGEX_REMOVE_ROOT_IDS, ''); html = html.replace(REGEX_REMOVE_IDS, ''); } return html end |
#instance ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/react/test/session.rb', line 11 def instance unless @instance @container = `document.createElement('div')` @instance = React.render(@element, @container) end @instance end |
#mount(component_klass, params = {}) ⇒ Object
6 7 8 9 |
# File 'lib/react/test/session.rb', line 6 def mount(component_klass, params = {}) @element = React.create_element(component_klass, params) instance end |