chore(spec): defined expected with type safety
This commit is contained in:
parent
6d647cd9bc
commit
f324e9e303
|
@ -1,5 +1,6 @@
|
|||
local assert = require("luassert")
|
||||
local scraper = require("scraper").module_doc
|
||||
local type Node = require("types.Node")
|
||||
local scraper = require("scraper.module_doc")
|
||||
|
||||
local get_doc_from_page = scraper.get_doc_from_page
|
||||
|
||||
|
@ -17,7 +18,9 @@ describe("Scrap documentation", function()
|
|||
name = "Empty",
|
||||
token = "module",
|
||||
})
|
||||
assert.same(nodes, {})
|
||||
local expected <const>: Node = {}
|
||||
assert.same(expected, ast)
|
||||
assert.same({}, nodes)
|
||||
end)
|
||||
|
||||
it("should produce Variable and `property::` Signal nodes", function()
|
||||
|
@ -57,7 +60,7 @@ describe("Scrap documentation", function()
|
|||
</dd>
|
||||
</dl>
|
||||
]], "property_signal")
|
||||
assert.same(ast, {
|
||||
local expected <const>: Node = {
|
||||
children = {
|
||||
{
|
||||
children = {
|
||||
|
@ -77,7 +80,8 @@ describe("Scrap documentation", function()
|
|||
},
|
||||
name = "Property_signal",
|
||||
token = "module",
|
||||
})
|
||||
}
|
||||
assert.same(expected, ast)
|
||||
end)
|
||||
|
||||
it("should produce Enum nodes when an Object Property type is a String with constraints", function()
|
||||
|
@ -150,7 +154,7 @@ describe("Scrap documentation", function()
|
|||
</dd>
|
||||
</dl>
|
||||
]], "property_enum")
|
||||
assert.same(ast, {
|
||||
local expected <const>: Node = {
|
||||
children = {
|
||||
{
|
||||
children = {
|
||||
|
@ -188,7 +192,8 @@ describe("Scrap documentation", function()
|
|||
},
|
||||
name = "Property_enum",
|
||||
token = "module",
|
||||
})
|
||||
}
|
||||
assert.same(expected, ast)
|
||||
end)
|
||||
|
||||
it("should produce a `string` typed Variable node when a String Property has no constraint", function()
|
||||
|
@ -208,7 +213,7 @@ describe("Scrap documentation", function()
|
|||
</dd>
|
||||
</dl>
|
||||
]], "property_string")
|
||||
assert.same(ast, {
|
||||
local expected <const>: Node = {
|
||||
children = {
|
||||
{
|
||||
children = {
|
||||
|
@ -228,7 +233,8 @@ describe("Scrap documentation", function()
|
|||
},
|
||||
name = "Property_string",
|
||||
token = "module",
|
||||
})
|
||||
}
|
||||
assert.same(expected, ast)
|
||||
end)
|
||||
|
||||
it("should provide a Function node with the `self` as the first positional parameter", function()
|
||||
|
@ -266,7 +272,7 @@ describe("Scrap documentation", function()
|
|||
</dd>
|
||||
</dl>
|
||||
]], "awful.tag")
|
||||
assert.same(ast, {
|
||||
local expected <const>: Node = {
|
||||
children = {
|
||||
{
|
||||
children = {},
|
||||
|
@ -293,7 +299,8 @@ describe("Scrap documentation", function()
|
|||
},
|
||||
name = "Tag",
|
||||
token = "module",
|
||||
})
|
||||
}
|
||||
assert.same(expected, ast)
|
||||
end)
|
||||
|
||||
it("should produce Signal nodes", function()
|
||||
|
@ -324,7 +331,7 @@ describe("Scrap documentation", function()
|
|||
<dd></dd>
|
||||
</dl>
|
||||
]], "signal")
|
||||
assert.same(ast, {
|
||||
local expected <const>: Node = {
|
||||
children = {
|
||||
{
|
||||
children = {
|
||||
|
@ -343,7 +350,8 @@ describe("Scrap documentation", function()
|
|||
},
|
||||
name = "Signal",
|
||||
token = "module",
|
||||
})
|
||||
}
|
||||
assert.same(expected, ast)
|
||||
end)
|
||||
|
||||
it("should produce Function nodes", function()
|
||||
|
@ -409,7 +417,7 @@ describe("Scrap documentation", function()
|
|||
</dd>
|
||||
</dl>
|
||||
]], "awesome") -- The module name must be the same as the module name in the doc
|
||||
assert.same(ast, {
|
||||
local expected <const>: Node = {
|
||||
children = {
|
||||
{
|
||||
children = {},
|
||||
|
@ -436,7 +444,8 @@ describe("Scrap documentation", function()
|
|||
},
|
||||
name = "Awesome",
|
||||
token = "module",
|
||||
})
|
||||
}
|
||||
assert.same(expected, ast)
|
||||
end)
|
||||
|
||||
-- TODO : Fix the code then come back to this test, the current implementation is incomplete
|
||||
|
@ -593,7 +602,7 @@ describe("Scrap documentation", function()
|
|||
</dd>
|
||||
</dl>
|
||||
]], "awful.client")
|
||||
assert.same(ast, {
|
||||
local expected_ast <const>: Node = {
|
||||
children = {
|
||||
{
|
||||
children = {},
|
||||
|
@ -603,14 +612,16 @@ describe("Scrap documentation", function()
|
|||
},
|
||||
name = "Client",
|
||||
token = "module",
|
||||
})
|
||||
assert.same(other_nodes, {
|
||||
}
|
||||
assert.same(expected_ast, ast)
|
||||
local expected_other_nodes <const>: { Node } = {
|
||||
{
|
||||
parameters = {},
|
||||
return_types = { "integer" },
|
||||
name = "client.instances",
|
||||
token = "function",
|
||||
}
|
||||
})
|
||||
}
|
||||
assert.same(expected_other_nodes, other_nodes)
|
||||
end)
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue