u.nvim/spec/codewriter_spec.lua
Jonathan Apodaca 121e0c0f7a
All checks were successful
NeoVim tests / plenary-tests (push) Successful in 8s
rebrand to u.nvim
2024-10-23 17:01:12 -06:00

30 lines
628 B
Lua

local CodeWriter = require 'u.codewriter'
describe('CodeWriter', function()
it('should write with indentation', function()
local cw = CodeWriter.new()
cw:write '{'
cw:indent(function(cw2) cw2:write 'x: 123' end)
cw:write '}'
assert.are.same(cw.lines, { '{', ' x: 123', '}' })
end)
it('should keep relative indentation', function()
local cw = CodeWriter.new()
cw:write '{'
cw:indent(function(cw2)
cw2:write 'x: 123'
cw2:write ' y: 123'
end)
cw:write '}'
assert.are.same(cw.lines, {
'{',
' x: 123',
' y: 123',
'}',
})
end)
end)