1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
-- luacheck: globals describe it assert before_each after_each
local _99 = require("99")
local Window = require("99.window")
local test_utils = require("99.test.test_utils")
local eq = assert.are.same
describe("state", function()
local provider
local previous_list_uis
before_each(function()
provider = test_utils.TestProvider.new()
_99.setup(test_utils.get_test_setup_options({
in_flight_options = { enable = false },
}, provider))
previous_list_uis = vim.api.nvim_list_uis
vim.api.nvim_list_uis = function()
return {
{ width = 120, height = 40 },
}
end
end)
after_each(function()
Window.clear_active_popups()
vim.cmd("silent! cclose")
vim.api.nvim_list_uis = previous_list_uis
end)
it("is active when capture input window is open", function()
local state = _99.__get_state()
eq(false, state:active())
Window.capture_input("Prompt", {
cb = function() end,
keymap = {
[":w"] = "submit",
},
})
eq(true, state:active())
end)
it("is active when quickfix window is open", function()
local state = _99.__get_state()
local buffer = test_utils.create_file({ "hello" }, "lua", 1, 0)
eq(false, state:active())
vim.fn.setqflist({}, "r", {
title = "99 Results",
items = {
{
bufnr = buffer,
lnum = 1,
col = 1,
text = "note",
},
},
})
vim.cmd("copen")
eq(true, state:active())
end)
end)
|