mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-29 07:05:12 -07:00
Merge pull request #1674 from Shopify/better-test-to-liquid-value
Improve test coverage of the to_liquid_value feature.
This commit is contained in:
@@ -24,13 +24,17 @@ class VariableTest < Minitest::Test
|
|||||||
|
|
||||||
def test_if_tag_calls_to_liquid_value
|
def test_if_tag_calls_to_liquid_value
|
||||||
assert_template_result('one', '{% if foo == 1 %}one{% endif %}', { 'foo' => IntegerDrop.new('1') })
|
assert_template_result('one', '{% if foo == 1 %}one{% endif %}', { 'foo' => IntegerDrop.new('1') })
|
||||||
|
assert_template_result('one', '{% if foo == eqv %}one{% endif %}', { 'foo' => IntegerDrop.new(1), 'eqv' => IntegerDrop.new(1) })
|
||||||
assert_template_result('one', '{% if 0 < foo %}one{% endif %}', { 'foo' => IntegerDrop.new('1') })
|
assert_template_result('one', '{% if 0 < foo %}one{% endif %}', { 'foo' => IntegerDrop.new('1') })
|
||||||
assert_template_result('one', '{% if foo > 0 %}one{% endif %}', { 'foo' => IntegerDrop.new('1') })
|
assert_template_result('one', '{% if foo > 0 %}one{% endif %}', { 'foo' => IntegerDrop.new('1') })
|
||||||
|
assert_template_result('one', '{% if b > a %}one{% endif %}', { 'b' => IntegerDrop.new(1), 'a' => IntegerDrop.new(0) })
|
||||||
assert_template_result('true', '{% if foo == true %}true{% endif %}', { 'foo' => BooleanDrop.new(true) })
|
assert_template_result('true', '{% if foo == true %}true{% endif %}', { 'foo' => BooleanDrop.new(true) })
|
||||||
assert_template_result('true', '{% if foo %}true{% endif %}', { 'foo' => BooleanDrop.new(true) })
|
assert_template_result('true', '{% if foo %}true{% endif %}', { 'foo' => BooleanDrop.new(true) })
|
||||||
|
|
||||||
assert_template_result('', '{% if foo %}true{% endif %}', { 'foo' => BooleanDrop.new(false) })
|
assert_template_result('', '{% if foo %}true{% endif %}', { 'foo' => BooleanDrop.new(false) })
|
||||||
assert_template_result('', '{% if foo == true %}True{% endif %}', { 'foo' => BooleanDrop.new(false) })
|
assert_template_result('', '{% if foo == true %}True{% endif %}', { 'foo' => BooleanDrop.new(false) })
|
||||||
|
|
||||||
|
assert_template_result('one', '{% if a contains x %}one{% endif %}', { 'a' => [1], 'x' => IntegerDrop.new(1) })
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unless_tag_calls_to_liquid_value
|
def test_unless_tag_calls_to_liquid_value
|
||||||
|
|||||||
@@ -131,10 +131,6 @@ class IntegerDrop < Liquid::Drop
|
|||||||
@value = value.to_i
|
@value = value.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
def ==(other)
|
|
||||||
@value == other
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
@value.to_s
|
@value.to_s
|
||||||
end
|
end
|
||||||
@@ -150,10 +146,6 @@ class BooleanDrop < Liquid::Drop
|
|||||||
@value = value
|
@value = value
|
||||||
end
|
end
|
||||||
|
|
||||||
def ==(other)
|
|
||||||
@value == other
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_liquid_value
|
def to_liquid_value
|
||||||
@value
|
@value
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user