ash/test/query/function/string_split_test.exs
2023-07-12 15:11:21 -04:00

21 lines
615 B
Elixir

defmodule Ash.Query.Function.StringSplitTest do
use ExUnit.Case, async: true
import Ash.Expr
test "strings are split on the separator" do
assert ["fo", "ar"] = eval!(expr(string_split("foo-bar", "o-b")))
end
test "strings are split on characters if a separator is not set" do
assert ["a", "b"] = eval!(expr(string_split("a b")))
end
test "splits are not trimmed by default" do
assert ["", "a", "b", ""] = eval!(expr(string_split("ab", "")))
end
test "splits can be trimmed on request" do
assert ["", "a", "b", ""] = eval!(expr(string_split("ab", "", split?: true)))
end
end