2022-09-07 20:11:49 +00:00
|
|
|
local vim_mock = require "ivy.vim_mock"
|
2022-09-04 13:01:02 +00:00
|
|
|
local window = require "ivy.window"
|
|
|
|
|
|
|
|
|
|
before_each(function()
|
2022-09-07 20:11:49 +00:00
|
|
|
vim_mock.reset()
|
2022-09-04 13:01:02 +00:00
|
|
|
end)
|
|
|
|
|
|
2022-09-18 17:15:14 +00:00
|
|
|
it("can initialize and destroy the window", function(t)
|
2022-09-04 13:01:02 +00:00
|
|
|
window.initialize()
|
|
|
|
|
|
2022-09-18 17:15:14 +00:00
|
|
|
t.assert_equal(10, window.get_buffer())
|
|
|
|
|
t.assert_equal(10, window.buffer)
|
|
|
|
|
|
|
|
|
|
window.destroy()
|
|
|
|
|
t.assert_equal(nil, window.buffer)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("can set items", function(t)
|
|
|
|
|
window.initialize()
|
|
|
|
|
|
|
|
|
|
window.set_items { { content = "Line one" } }
|
|
|
|
|
t.assert_equal("Line one", window.get_current_selection())
|
2022-09-04 13:01:02 +00:00
|
|
|
end)
|
2023-10-22 17:02:50 +00:00
|
|
|
|
|
|
|
|
it("will set the items when a string is passed in", function(t)
|
|
|
|
|
window.initialize()
|
|
|
|
|
|
|
|
|
|
local items = table.concat({ "One", "Two", "Three" }, "\n")
|
|
|
|
|
window.set_items(items)
|
|
|
|
|
|
|
|
|
|
local lines = table.concat(vim_mock.get_lines()[window.buffer], "\n")
|
|
|
|
|
t.assert_equal(items, lines)
|
|
|
|
|
end)
|