-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a8b75b
commit e0d54cc
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class CycleTagTest < Minitest::Test | ||
def test_simple_cycle | ||
template = <<~LIQUID | ||
{%- cycle '1', '2', '3' -%} | ||
{%- cycle '1', '2', '3' -%} | ||
{%- cycle '1', '2', '3' -%} | ||
LIQUID | ||
|
||
assert_template_result("123", template) | ||
end | ||
|
||
def test_simple_cycle_inside_for_loop | ||
template = <<~LIQUID | ||
{%- for i in (1..3) -%} | ||
{% cycle '1', '2', '3' %} | ||
{%- endfor -%} | ||
LIQUID | ||
|
||
assert_template_result("123", template) | ||
end | ||
|
||
def test_cycle_with_variables_inside_for_loop | ||
template = <<~LIQUID | ||
{%- assign a = 1 -%} | ||
{%- assign b = 2 -%} | ||
{%- assign c = 3 -%} | ||
{%- for i in (1..3) -%} | ||
{% cycle a, b, c %} | ||
{%- endfor -%} | ||
LIQUID | ||
|
||
assert_template_result("123", template) | ||
end | ||
|
||
def test_cycle_tag_always_resets_cycle | ||
template = <<~LIQUID | ||
{%- assign a = "1" -%} | ||
{%- cycle a, "2" -%} | ||
{%- cycle a, "2" -%} | ||
LIQUID | ||
|
||
assert_template_result("11", template) | ||
end | ||
end |