-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstringcase.test.lua
More file actions
36 lines (33 loc) · 1.5 KB
/
Copy pathstringcase.test.lua
File metadata and controls
36 lines (33 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local stringcase = require "mods.stringcase"
local fmt = string.format
describe("mods.stringcase", function()
-- stylua: ignore
local tests = {
-----fname----|-------------expected--------------
{ "capitalize", { "Foo_bar-baz" , "Foobar baz" } },
{ "sentence" , { "Foo_bar-baz" , "FooBar baz" } },
{ "swapcase" , { "FOO_BAR-BAZ" , "fOObAR BAZ" } },
{ "lower" , { "foo_bar-baz" , "foobar baz" } },
{ "upper" , { "FOO_BAR-BAZ" , "FOOBAR BAZ" } },
{ "acronym" , { "FBB" } },
{ "camel" , { "fooBarBaz" } },
{ "pascal" , { "FooBarBaz" } },
{ "snake" , { "foo_bar_baz" } },
{ "delimit" , { "foobarbaz" } },
{ "kebab" , { "foo-bar-baz" } },
{ "title" , { "Foo Bar Baz" } },
{ "dot" , { "foo.bar.baz" } },
{ "path" , { "foo/bar/baz" } },
{ "space" , { "foo bar baz" } },
{ "constant" , { "FOO_BAR_BAZ" } },
}
for i = 1, #tests do
local fname, expected = unpack(tests[i] --[[@as {[1]:string, [2]:string[]}]], 1, 2)
for j, s in ipairs({ "foo_bar-baz", "FooBar baz" }) do
it(fmt("%s(%q) returns correct result", fname, s), function()
-- Wrap in a table to make sure the function returns only one value.
assert.are_same({ expected[j] or expected[1] }, { stringcase[fname](s) })
end)
end
end
end)