Sha256: 35b2509411bf034d2f242bbf08c2ec2f5691ab69318f4f4223b152aa935a7a7b

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

# frozen-string-literal: true
require 'spec_helper'

RSpec.describe 'JavaScript filter rendering', type: :render do
  it 'renders javascript filter' do
    expect(render_string(<<HAML)).to eq("<div>\n<script>\n  alert('hello');\n</script>\n<span>world</span>\n</div>\n")
%div
  :javascript
    alert('hello');
  %span world
HAML
  end

  it 'keeps indent' do
    expect(render_string(<<HAML)).to eq("<div>\n<script>\n  alert('hello');\n  \n      alert('world');\n</script>\n</div>\n")
%div
  :javascript
    alert('hello');

        alert('world');
HAML
  end

  it 'ignores empty filter' do
    expect(render_string(<<HAML)).to eq("<div>\n<span>world</span>\n</div>\n")
%div
  :javascript
  %span world
HAML
  end

  it 'parses string interpolation' do
    expect(render_string(<<'HAML')).to eq("<script>\n  var x = 3;\n</script>\n")
:javascript
  var x = #{1 + 2};
HAML
  end

  it "doesn't escape in string interpolation" do
    expect(render_string(<<'HAML')).to eq("<script>\n  <span/>\n</script>\n")
:javascript
  #{'<span/>'}
HAML
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
faml-0.7.3 spec/render/filters/javascript_spec.rb
faml-0.7.2 spec/render/filters/javascript_spec.rb
faml-0.7.1 spec/render/filters/javascript_spec.rb
faml-0.7.0 spec/render/filters/javascript_spec.rb
faml-0.6.5 spec/render/filters/javascript_spec.rb
faml-0.6.4 spec/render/filters/javascript_spec.rb
faml-0.6.3 spec/render/filters/javascript_spec.rb
faml-0.6.2 spec/render/filters/javascript_spec.rb
faml-0.6.1 spec/render/filters/javascript_spec.rb