Skip to content

Commit

Permalink
Add missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andershagbard committed Oct 16, 2023
1 parent 858428f commit 2800d8d
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions test/integration/standard_filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,45 @@ def test_uniq_invalid_property
end
end

def test_uniq_deep_default_separator
input = [
{ "foo" => { "bar" => "baz", "handle" => "alpha" } } ,
{ "foo" => { "bar" => "baz", "handle" => "beta" } } ,
{ "foo" => { "bar" => "qux", "handle" => "charlie" } } ,
]
expectation = [
{ "foo" => { "bar" => "baz", "handle" => "alpha" } } ,
{ "foo" => { "bar" => "qux", "handle" => "charlie" } } ,
]
assert_equal(expectation, @filters.uniq(input, "foo.bar", { "deep" => true }))
end

def test_uniq_deep_custom_separator
input = [
{ "foo" => { "bar" => "baz", "handle" => "alpha" } },
{ "foo" => { "bar" => "baz", "handle" => "beta" } },
{ "foo" => { "bar" => "qux", "handle" => "charlie" } },
]
expectation = [
{ "foo" => { "bar" => "baz", "handle" => "alpha" } },
{ "foo" => { "bar" => "qux", "handle" => "charlie" } },
]
assert_equal(expectation, @filters.uniq(input, "foo_bar", { "deep" => "_" }))
end

def test_uniq_deep_off_by_default
input = [
{ "foo.bar" => "baz", "handle" => "alpha" },
{ "foo.bar" => "baz", "handle" => "beta" },
{ "foo.bar" => "qux", "handle" => "charlie" },
]
expectation = [
{ "foo.bar" => "baz", "handle" => "alpha" },
{ "foo.bar" => "qux", "handle" => "charlie" },
]
assert_equal(expectation, @filters.uniq(input, "foo.bar"))
end

def test_compact_empty_array
assert_equal([], @filters.compact([], "a"))
end
Expand Down Expand Up @@ -1023,6 +1062,45 @@ def test_where_array_of_only_unindexable_values
assert_nil(@filters.where([nil], "ok"))
end

def test_where_deep_default_separator
input = [
{ "foo" => { "bar" => "baz", "handle" => "alpha" } },
{ "foo" => { "bar" => "baz", "handle" => "beta" } },
{ "foo" => { "bar" => "qux", "handle" => "charlie" } },
]
expectation = [
{ "foo" => { "bar" => "baz", "handle" => "alpha" } },
{ "foo" => { "bar" => "baz", "handle" => "beta" } },
]
assert_equal(expectation, @filters.where(input, "foo.bar", "baz", { "deep" => true }))
end

def test_where_deep_custom_separator
input = [
{ "foo" => { "bar" => "baz", "handle" => "alpha" } },
{ "foo" => { "bar" => "baz", "handle" => "beta" } },
{ "foo" => { "bar" => "qux", "handle" => "charlie" } },
]
expectation = [
{ "foo" => { "bar" => "baz", "handle" => "alpha" } },
{ "foo" => { "bar" => "baz", "handle" => "beta" } },
]
assert_equal(expectation, @filters.where(input, "foo_bar", "baz", { "deep" => "_" }))
end

def test_where_deep_off_by_default
input = [
{ "foo.bar" => "baz", "handle" => "alpha" },
{ "foo.bar" => "baz", "handle" => "beta" },
{ "foo.bar" => "qux", "handle" => "charlie" },
]
expectation = [
{ "foo.bar" => "baz", "handle" => "alpha" },
{ "foo.bar" => "baz", "handle" => "beta" },
]
assert_equal(expectation, @filters.where(input, "foo.bar", "baz"))
end

def test_all_filters_never_raise_non_liquid_exception
test_drop = TestDrop.new(value: "test")
test_drop.context = Context.new
Expand Down

0 comments on commit 2800d8d

Please sign in to comment.