spec(module_doc): add basic test
ci/woodpecker/pr/docker-build Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/pr/build Pipeline was successful Details
ci/woodpecker/pr/test Pipeline was successful Details

This commit is contained in:
Aire-One 2023-05-04 00:45:39 +02:00
parent 592e62d6fa
commit 5d45637954
3 changed files with 22 additions and 40 deletions

View File

@ -1,30 +0,0 @@
local assert = require("luassert")
describe("Busted unit testing framework", function()
describe("should be awesome", function()
it("should be easy to use", function()
assert.truthy "Yup."
end)
it("should have lots of features", function()
-- deep check comparisons!
assert.same({ table = "great" }, { table = "great" })
-- or check by reference!
assert.not_equal({ table = "great" }, { table = "great" })
assert.truthy "this is a string" -- truthy: not false or nil
assert.is_true(1 == 1)
assert.falsy(nil)
assert.has_error(function()
error "Wat"
end, "Wat")
end)
it("should provide some shortcuts to common functions", function()
assert.is_unique { { thing = 1 }, { thing = 2 }, { thing = 3 } }
end)
end)
end)

View File

@ -1,10 +0,0 @@
local assert = require("luassert")
local utils = require("utils")
describe("test", function()
it("has_item", function()
local t = {1, 2, 3}
assert.equal(utils.has_item(t, 1), 1)
assert.is_nil(utils.has_item(t, 4))
end)
end)

View File

@ -0,0 +1,22 @@
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)
end)