This commit is contained in:
@@ -1,59 +1,7 @@
|
||||
local Renderer = require 'u.renderer'
|
||||
|
||||
--- @param markup string
|
||||
local function parse(markup)
|
||||
-- call private method:
|
||||
return (Renderer --[[@as any]])._parse_markup(markup)
|
||||
end
|
||||
|
||||
describe('Renderer', function()
|
||||
it('_parse_markup: empty string', function()
|
||||
local nodes = parse [[]]
|
||||
assert.are.same({}, nodes)
|
||||
end)
|
||||
|
||||
it('_parse_markup: only string', function()
|
||||
local nodes = parse [[The quick brown fox jumps over the lazy dog.]]
|
||||
assert.are.same({
|
||||
{ kind = 'text', value = 'The quick brown fox jumps over the lazy dog.' },
|
||||
}, nodes)
|
||||
end)
|
||||
|
||||
it('_parse_markup: <', function()
|
||||
local nodes = parse [[<t value="bleh" />]]
|
||||
assert.are.same({
|
||||
{ kind = 'text', value = '<t value="bleh" />' },
|
||||
}, nodes)
|
||||
end)
|
||||
|
||||
it('_parse_markup: empty tag', function()
|
||||
local nodes = parse [[</>]]
|
||||
assert.are.same({ { kind = 'tag', name = '', attributes = {} } }, nodes)
|
||||
end)
|
||||
|
||||
it('_parse_markup: tag', function()
|
||||
local nodes = parse [[<t value="Hello" />]]
|
||||
assert.are.same({
|
||||
{
|
||||
kind = 'tag',
|
||||
name = 't',
|
||||
attributes = {
|
||||
value = 'Hello',
|
||||
},
|
||||
},
|
||||
}, nodes)
|
||||
end)
|
||||
|
||||
it('_parse_markup: attributes with quotes', function()
|
||||
local nodes = parse [[<t value="Hello \"there\"" />]]
|
||||
assert.are.same({
|
||||
{
|
||||
kind = 'tag',
|
||||
name = 't',
|
||||
attributes = {
|
||||
value = 'Hello "there"',
|
||||
},
|
||||
},
|
||||
}, nodes)
|
||||
it('markup_to_string', function()
|
||||
assert.are.equal(true, false) -- TODO
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user