mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-16 21:12:59 +00:00
47 lines
898 B
Lua
47 lines
898 B
Lua
|
local polyfill = require("worldeditadditions.utils.strings.polyfill")
|
||
|
|
||
|
describe("trim", function()
|
||
|
it("work for a string that's already trimmed", function()
|
||
|
assert.are.equal(
|
||
|
polyfill.trim("test"),
|
||
|
"test"
|
||
|
)
|
||
|
end)
|
||
|
it("trim from the start", function()
|
||
|
assert.are.equal(
|
||
|
polyfill.trim(" test"),
|
||
|
"test"
|
||
|
)
|
||
|
end)
|
||
|
it("trim from the end", function()
|
||
|
assert.are.equal(
|
||
|
polyfill.trim("test "),
|
||
|
"test"
|
||
|
)
|
||
|
end)
|
||
|
it("trim from both ends", function()
|
||
|
assert.are.equal(
|
||
|
polyfill.trim(" test "),
|
||
|
"test"
|
||
|
)
|
||
|
end)
|
||
|
it("trim another string", function()
|
||
|
assert.are.equal(
|
||
|
polyfill.trim("yay "),
|
||
|
"yay"
|
||
|
)
|
||
|
end)
|
||
|
it("trim tabs", function()
|
||
|
assert.are.equal(
|
||
|
polyfill.trim("//forest "),
|
||
|
"//forest"
|
||
|
)
|
||
|
end)
|
||
|
it("avoid trimming spaces in the middle", function()
|
||
|
assert.are.equal(
|
||
|
polyfill.trim("te st "),
|
||
|
"te st"
|
||
|
)
|
||
|
end)
|
||
|
end)
|