mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
refactor comment tag unit test to use test helper
This commit is contained in:
@@ -4,7 +4,7 @@ require 'test_helper'
|
|||||||
|
|
||||||
class CommentTagUnitTest < Minitest::Test
|
class CommentTagUnitTest < Minitest::Test
|
||||||
def test_does_not_parse_nodes_inside_a_comment
|
def test_does_not_parse_nodes_inside_a_comment
|
||||||
template = Liquid::Template.parse(<<~LIQUID.chomp, line_numbers: true)
|
assert_template_result("", <<~LIQUID.chomp)
|
||||||
{% comment %}
|
{% comment %}
|
||||||
{% if true %}
|
{% if true %}
|
||||||
{% if ... %}
|
{% if ... %}
|
||||||
@@ -16,22 +16,31 @@ class CommentTagUnitTest < Minitest::Test
|
|||||||
{% endcase %}
|
{% endcase %}
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
LIQUID
|
LIQUID
|
||||||
|
|
||||||
assert_equal("", template.render)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_allows_incomplete_tags_inside_a_comment
|
def test_allows_incomplete_tags_inside_a_comment
|
||||||
template = Liquid::Template.parse(<<~LIQUID.chomp, line_numbers: true)
|
assert_template_result("", <<~LIQUID.chomp)
|
||||||
{% comment %}
|
{% comment %}
|
||||||
{% assign foo = "1"
|
{% assign foo = "1"
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
LIQUID
|
LIQUID
|
||||||
|
|
||||||
assert_equal("", template.render)
|
assert_template_result("", <<~LIQUID.chomp)
|
||||||
|
{% comment %}
|
||||||
|
{% comment %}
|
||||||
|
{% invalid
|
||||||
|
{% endcomment %}
|
||||||
|
{% endcomment %}
|
||||||
|
LIQUID
|
||||||
|
|
||||||
|
assert_template_result("", <<~LIQUID.chomp)
|
||||||
|
{% comment %}
|
||||||
|
{% {{ {%- endcomment %}
|
||||||
|
LIQUID
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_child_comment_tags_need_to_be_closed
|
def test_child_comment_tags_need_to_be_closed
|
||||||
template = Liquid::Template.parse(<<~LIQUID.chomp, line_numbers: true)
|
assert_template_result("", <<~LIQUID.chomp)
|
||||||
{% comment %}
|
{% comment %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
{% comment %}{% endcomment %}
|
{% comment %}{% endcomment %}
|
||||||
@@ -39,10 +48,8 @@ class CommentTagUnitTest < Minitest::Test
|
|||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
LIQUID
|
LIQUID
|
||||||
|
|
||||||
assert_equal("", template.render)
|
|
||||||
|
|
||||||
assert_raises(Liquid::SyntaxError) do
|
assert_raises(Liquid::SyntaxError) do
|
||||||
Liquid::Template.parse(<<~LIQUID.chomp, line_numbers: true)
|
assert_template_result("", <<~LIQUID.chomp)
|
||||||
{% comment %}
|
{% comment %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
@@ -53,7 +60,7 @@ class CommentTagUnitTest < Minitest::Test
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_child_raw_tags_need_to_be_closed
|
def test_child_raw_tags_need_to_be_closed
|
||||||
template = Liquid::Template.parse(<<~LIQUID.chomp, line_numbers: true)
|
assert_template_result("", <<~LIQUID.chomp)
|
||||||
{% comment %}
|
{% comment %}
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
@@ -61,10 +68,8 @@ class CommentTagUnitTest < Minitest::Test
|
|||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
LIQUID
|
LIQUID
|
||||||
|
|
||||||
assert_equal("", template.render)
|
|
||||||
|
|
||||||
assert_raises(Liquid::SyntaxError) do
|
assert_raises(Liquid::SyntaxError) do
|
||||||
Liquid::Template.parse(<<~LIQUID.chomp, line_numbers: true)
|
Liquid::Template.parse(<<~LIQUID.chomp)
|
||||||
{% comment %}
|
{% comment %}
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|||||||
Reference in New Issue
Block a user