Skip to content

Commit

Permalink
Add tests for skip_display_none config option.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronvb committed Jan 23, 2016
1 parent cae4eeb commit ce9d3b0
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 0 deletions.
Empty file modified README.md
100755 → 100644
Empty file.
Empty file modified app/helpers/react_on_rails_helper.rb
100755 → 100644
Empty file.
Empty file.
Empty file modified lib/react_on_rails/configuration.rb
100755 → 100644
Empty file.
3 changes: 3 additions & 0 deletions spec/dummy/config/initializers/react_on_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@
# Server rendering only (not for render_component helper)
config.server_renderer_pool_size = 1 # increase if you're on JRuby
config.server_renderer_timeout = 20 # seconds

# Default is false, enable if your content security policy doesn't include `style-src: 'unsafe-inline'`
config.skip_display_none = false
end
15 changes: 15 additions & 0 deletions spec/dummy/spec/helpers/react_on_rails_helper_spec.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@
it { is_expected.not_to include react_component_div }
it { is_expected.to include react_definition_div }
end

context "with skip_display_none option" do
before { ReactOnRails.configuration.skip_display_none = true }

let(:react_definition_div_skip_display_none) do
"<div class=\"js-react-on-rails-component\"
data-component-name=\"App\"
data-props=\"{&quot;name&quot;:&quot;My Test Name&quot;}\"
data-trace=\"false\"
data-expect-turbolinks=\"true\"
data-dom-id=\"#{id}\"></div>".squish
end

it { is_expected.to include react_definition_div_skip_display_none }
end
end

describe "#server_render_js" do
Expand Down
13 changes: 13 additions & 0 deletions spec/react_on_rails/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,18 @@ module ReactOnRails
expect(ReactOnRails.configuration.server_bundle_js_file).to eq("client/dist/something.js")
expect(ReactOnRails.configuration.prerender).to eq(true)
end

context "skip display: none" do
it "will default false" do
expect(ReactOnRails.configuration.skip_display_none).to eq(false)
end

it "will be true if set to true" do
ReactOnRails.configure do |config|
config.skip_display_none = true
end
expect(ReactOnRails.configuration.skip_display_none).to eq(true)
end
end
end
end

0 comments on commit ce9d3b0

Please sign in to comment.