require "test_helper"
require_relative "../../../../app/models/builder/liquid_ext/javascript_block"

class Builder::LiquidExt::JavascriptBlockTest < ActiveSupport::TestCase
  test "should get inner js code" do
    text0 = "{% javascript %}alert('hello'); {% endjavascript %}"
    @template = Liquid::Template.parse(text0)
    @template.render

    assert_equal ["alert('hello');"], @template.instance_assigns["jscode"]
  end

  test "should get inner js code snipet" do
    text1 = "{% javascript %}alert('hello'); {% endjavascript %} and {% javascript %}alert('world');{% endjavascript %}"
    @template = Liquid::Template.parse(text1)
    @template.render
    assert_equal ["alert('hello');", "alert('world');"], @template.instance_assigns["jscode"]
  end
end
