Testing If Tag Conditional Logic Implementation in Shopify/Liquid
This test suite validates the functionality of Liquid’s if tag implementation, focusing on the proper parsing and evaluation of conditional statements in templates. The tests ensure the nodelist structure maintains correct branching logic for if/else conditions.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
shopify/liquid
test/unit/tags/if_tag_unit_test.rb
# frozen_string_literal: true
require 'test_helper'
class IfTagUnitTest < Minitest::Test
def test_if_nodelist
template = Liquid::Template.parse('{% if true %}IF{% else %}ELSE{% endif %}')
assert_equal(['IF', 'ELSE'], template.root.nodelist[0].nodelist.map(&:nodelist).flatten)
end
end