awesomewm.d.tl/spec/scraper/module_doc_spec.tl

73 lines
2.1 KiB
Plaintext
Raw Normal View History

2023-05-04 00:45:39 +02:00
local assert = require("luassert")
local scraper = require("scraper").module_doc
local get_doc_from_page = scraper.get_doc_from_page
describe("Scrap documentation", function()
it("should return a valid AST for an empty module", function()
local ast <const>, nodes <const> = get_doc_from_page("", "empty")
assert.same(ast, {
children = {
{
children = {},
name = "Signal",
token = "enum",
}
},
name = "Empty",
token = "module",
})
assert.same(nodes, {})
end)
2023-05-04 00:46:27 +02:00
it("should produce Signal nodes", function()
local ast <const> = get_doc_from_page([[
<h2 class="section-header"><a name="Signals"></a>Signals</h2>
<dl class="function">
<dt>
<a
class="copy-link js-copy-link"
name="widget::layout_changed"
href="#widget::layout_changed"
>🔗</a
>
<strong>widget::layout_changed</strong>
<span class="baseclass"> ·&nbsp;Inherited from wibox.widget.base </span>
</dt>
<dd></dd>
<dt>
<a
class="copy-link js-copy-link"
name="widget::redraw_needed"
href="#widget::redraw_needed"
>🔗</a
>
<strong>widget::redraw_needed</strong>
<span class="baseclass"> ·&nbsp;Inherited from wibox.widget.base </span>
</dt>
<dd></dd>
</dl>
]], "signal")
assert.same(ast, {
children = {
{
children = {
{
name = "widget::layout_changed",
token = "identifier",
},
{
name = "widget::redraw_needed",
token = "identifier",
},
},
name = "Signal",
token = "enum",
},
},
name = "Signal",
token = "module",
})
end)
2023-05-04 00:45:39 +02:00
end)