@@ -23,47 +23,47 @@ local T = MiniTest.new_set({
23
23
},
24
24
})
25
25
26
+ local function test_string (child , str )
27
+ child .lua ([[ require('text-transform').setup()]] )
28
+ child .lua ([[ result = require('text-transform').to_words("]] .. str .. [[ ")]] )
29
+ end
30
+
26
31
T [" to_words()" ] = MiniTest .new_set ()
27
32
28
- T [" to_words()" ][" should split two words with spaces" ] = function ()
29
- child .lua ([[ require('text-transform').setup()]] )
30
- child .lua ([[ result = require('text-transform').to_words("hello world")]] )
33
+ T [" to_words()" ][" should split normal spaced words" ] = function ()
34
+ test_string (child , " hello world" )
31
35
eq_type_global (child , " result" , " table" )
32
- eq_global (child , " result[1]" , " hello" )
33
- eq_global (child , " result[2]" , " world" )
36
+ eq_global (child , " result" , { " hello" , " world" })
34
37
end
35
38
36
- T [" to_words()" ][" should split two words with no spaces" ] = function ()
37
- child .lua ([[ require('text-transform').setup()]] )
38
- child .lua ([[ result = require('text-transform').to_words("helloWorld")]] )
39
+ T [" to_words()" ][" should split camel case strings" ] = function ()
40
+ test_string (child , " helloWorld" )
39
41
eq_type_global (child , " result" , " table" )
40
- eq_global (child , " result[1]" , " hello" )
41
- eq_global (child , " result[2]" , " world" )
42
+ eq_global (child , " result" , { " hello" , " world" })
42
43
end
43
44
44
- T [" to_words()" ][" should split two words with dots" ] = function ()
45
- child .lua ([[ require('text-transform').setup()]] )
46
- child .lua ([[ result = require('text-transform').to_words("hello.world")]] )
45
+ T [" to_words()" ][" should split dot case strings" ] = function ()
46
+ test_string (child , " hello.world" )
47
47
eq_type_global (child , " result" , " table" )
48
- eq_global (child , " result[1]" , " hello" )
49
- eq_global (child , " result[2]" , " world" )
48
+ eq_global (child , " result" , { " hello" , " world" })
50
49
end
51
50
52
- T [" to_words()" ][" should split two words with a number inside" ] = function ()
53
- child .lua ([[ require('text-transform').setup()]] )
54
- child .lua ([[ result = require('text-transform').to_words("helloWorld123")]] )
51
+ T [" to_words()" ][" should split const case strings" ] = function ()
52
+ test_string (child , " HELLO_WORLD" )
55
53
eq_type_global (child , " result" , " table" )
56
- eq_global (child , " result[1]" , " hello" )
57
- eq_global (child , " result[2]" , " world" )
58
- eq_global (child , " result[3]" , " 123" )
54
+ eq_global (child , " result" , { " hello" , " world" })
59
55
end
60
56
61
- T [" to_words()" ][" should split two words and ignore trailing/leading spaces" ] = function ()
62
- child .lua ([[ require('text-transform').setup()]] )
63
- child .lua ([[ result = require('text-transform').to_words(" hello world ")]] )
57
+ T [" to_words()" ][" should treat numbers as words" ] = function ()
58
+ test_string (child , " helloWorld123" )
59
+ eq_type_global (child , " result" , " table" )
60
+ eq_global (child , " result" , { " hello" , " world" , " 123" })
61
+ end
62
+
63
+ T [" to_words()" ][" should trim trailing/leading" ] = function ()
64
+ test_string (child , " hello world " )
64
65
eq_type_global (child , " result" , " table" )
65
- eq_global (child , " result[1]" , " hello" )
66
- eq_global (child , " result[2]" , " world" )
66
+ eq_global (child , " result" , { " hello" , " world" })
67
67
end
68
68
69
69
return T
0 commit comments