mirror of
https://github.com/zoriya/telescope.nvim.git
synced 2025-12-06 06:46:10 +00:00
fix: turns out tests weren't really asserting anything
This commit is contained in:
@@ -988,7 +988,10 @@ end
|
|||||||
|
|
||||||
function Picker:_on_complete()
|
function Picker:_on_complete()
|
||||||
for _, v in ipairs(self._completion_callbacks) do
|
for _, v in ipairs(self._completion_callbacks) do
|
||||||
pcall(v, self)
|
local ok, msg = pcall(v, self)
|
||||||
|
if not ok then
|
||||||
|
log.warn("completion callback failed with:", msg)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,9 @@ local execute_test_case = function(location, key, spec)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local end_test_cases = function()
|
local end_test_cases = vim.schedule_wrap(function()
|
||||||
vim.cmd [[qa!]]
|
vim.cmd [[qa!]]
|
||||||
end
|
end)
|
||||||
|
|
||||||
local invalid_test_case = function(k)
|
local invalid_test_case = function(k)
|
||||||
writer { case = k, expected = "<a valid key>", actual = k }
|
writer { case = k, expected = "<a valid key>", actual = k }
|
||||||
@@ -86,10 +86,6 @@ tester.picker_feed = function(input, test_cases)
|
|||||||
|
|
||||||
vim.wait(10)
|
vim.wait(10)
|
||||||
|
|
||||||
if tester.debug then
|
|
||||||
coroutine.yield()
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
if test_cases.post_typed then
|
if test_cases.post_typed then
|
||||||
for k, v in ipairs(test_cases.post_typed) do
|
for k, v in ipairs(test_cases.post_typed) do
|
||||||
@@ -173,7 +169,7 @@ local asserters = {
|
|||||||
local check_results = function(results)
|
local check_results = function(results)
|
||||||
-- TODO: We should get all the test cases here that fail, not just the first one.
|
-- TODO: We should get all the test cases here that fail, not just the first one.
|
||||||
for _, v in ipairs(results) do
|
for _, v in ipairs(results) do
|
||||||
local assertion = asserters[v._type or "default"]
|
local assertion = asserters[v._type or "_default"]
|
||||||
|
|
||||||
assertion(v.expected, v.actual, string.format("Test Case: %s // %s", v.location, v.case))
|
assertion(v.expected, v.actual, string.format("Test Case: %s // %s", v.location, v.case))
|
||||||
end
|
end
|
||||||
@@ -217,8 +213,6 @@ tester._execute = function(filename)
|
|||||||
-- Important so that the outputs don't get mixed
|
-- Important so that the outputs don't get mixed
|
||||||
log.use_console = false
|
log.use_console = false
|
||||||
|
|
||||||
vim.cmd(string.format("luafile %s", filename))
|
|
||||||
|
|
||||||
local f = loadfile(filename)
|
local f = loadfile(filename)
|
||||||
if not f then
|
if not f then
|
||||||
writer {
|
writer {
|
||||||
@@ -238,7 +232,7 @@ tester._execute = function(filename)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
end_test_cases()
|
-- end_test_cases()
|
||||||
end
|
end
|
||||||
|
|
||||||
return tester
|
return tester
|
||||||
|
|||||||
@@ -7,6 +7,16 @@ local disp = function(val)
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe("builtin.find_files", function()
|
describe("builtin.find_files", function()
|
||||||
|
it("should find the readme, using lowercase", function()
|
||||||
|
tester.run_string [[
|
||||||
|
tester.builtin_picker('find_files', 'readme.md', {
|
||||||
|
post_close = {
|
||||||
|
{ 'README.md', GetFile },
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]]
|
||||||
|
end)
|
||||||
|
|
||||||
it("should find the readme", function()
|
it("should find the readme", function()
|
||||||
tester.run_file "find_files__readme"
|
tester.run_file "find_files__readme"
|
||||||
end)
|
end)
|
||||||
@@ -50,7 +60,7 @@ describe("builtin.find_files", function()
|
|||||||
it("should only save one line for ascending, but many for descending", function()
|
it("should only save one line for ascending, but many for descending", function()
|
||||||
local expected
|
local expected
|
||||||
if configuration.sorting_strategy == "descending" then
|
if configuration.sorting_strategy == "descending" then
|
||||||
expected = 5
|
expected = 19
|
||||||
else
|
else
|
||||||
expected = 1
|
expected = 1
|
||||||
end
|
end
|
||||||
@@ -102,16 +112,6 @@ describe("builtin.find_files", function()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
it("should find the readme, using lowercase", function()
|
|
||||||
tester.run_string [[
|
|
||||||
tester.builtin_picker('find_files', 'readme.md', {
|
|
||||||
post_close = {
|
|
||||||
{ 'README.md', GetFile },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
]]
|
|
||||||
end)
|
|
||||||
|
|
||||||
it("should find the pickers.lua, using lowercase", function()
|
it("should find the pickers.lua, using lowercase", function()
|
||||||
tester.run_string [[
|
tester.run_string [[
|
||||||
tester.builtin_picker('find_files', 'pickers.lua', {
|
tester.builtin_picker('find_files', 'pickers.lua', {
|
||||||
@@ -139,10 +139,10 @@ describe("builtin.find_files", function()
|
|||||||
post_typed = {
|
post_typed = {
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
" lua/tests/fixtures/file_abc.txt",
|
"> lua/tests/fixtures/file_abc.txt",
|
||||||
"> lua/tests/fixtures/file_a.txt",
|
" lua/tests/fixtures/file_a.txt",
|
||||||
}, function()
|
}, function()
|
||||||
local res = GetResults()
|
local res = GetResults()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
res[#res - 1],
|
res[#res - 1],
|
||||||
|
|||||||
Reference in New Issue
Block a user