|
| 1 | +local Helpers = dofile("tests/scripts/helpers.lua") |
| 2 | +local child = MiniTest.new_child_neovim() |
| 3 | + |
| 4 | +local T = MiniTest.new_set({ |
| 5 | + hooks = { |
| 6 | + pre_case = function() |
| 7 | + child.restart({ "-u", "tests/scripts/init_with_zen.lua" }) |
| 8 | + end, |
| 9 | + post_once = child.stop, |
| 10 | + }, |
| 11 | +}) |
| 12 | + |
| 13 | +T["close zen side buffers on last main quit"] = function() |
| 14 | + Helpers.expect.layout(child, { |
| 15 | + type = "row", |
| 16 | + children = { |
| 17 | + { type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 50 }, |
| 18 | + { type = "leaf", filetype = "", buftype = "", width = 146, height = 50 }, |
| 19 | + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 50 }, |
| 20 | + }, |
| 21 | + }) |
| 22 | + |
| 23 | + pcall(child.cmd, "q") |
| 24 | + |
| 25 | + local STOPPED = 0 |
| 26 | + local exit_code = vim.fn.jobwait({ child.job.id }, 1000)[1] |
| 27 | + MiniTest.expect.equality(exit_code, STOPPED) |
| 28 | +end |
| 29 | + |
| 30 | +T["open zen side buffers on startup"] = function() |
| 31 | + Helpers.expect.layout(child, { |
| 32 | + type = "row", |
| 33 | + children = { |
| 34 | + { type = "leaf", filetype = "zen-left", buftype = "nofile", width = 46, height = 50 }, |
| 35 | + { type = "leaf", filetype = "", buftype = "", width = 146, height = 50 }, |
| 36 | + { type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 50 }, |
| 37 | + }, |
| 38 | + }) |
| 39 | +end |
| 40 | + |
| 41 | +T["do not open zen side buffers when there is not enough space"] = function() |
| 42 | + child.restart({ "-u", "tests/scripts/init_with_zen_small.lua" }) |
| 43 | + |
| 44 | + Helpers.expect.layout(child, { |
| 45 | + type = "leaf", |
| 46 | + filetype = "", |
| 47 | + buftype = "", |
| 48 | + width = 140, |
| 49 | + height = 50, |
| 50 | + }) |
| 51 | +end |
| 52 | + |
| 53 | +T["cursor does not enter zen side buffers"] = MiniTest.new_set({ |
| 54 | + hooks = { |
| 55 | + pre_case = function() |
| 56 | + child.restart({ "-u", "tests/scripts/init_with_zen.lua" }) |
| 57 | + child.cmd("edit test.lua") |
| 58 | + end, |
| 59 | + }, |
| 60 | +}) |
| 61 | + |
| 62 | +T["cursor does not enter zen side buffers"]["from main"] = function() |
| 63 | + child.cmd("wincmd h") |
| 64 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua") |
| 65 | + |
| 66 | + child.cmd("wincmd l") |
| 67 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua") |
| 68 | +end |
| 69 | + |
| 70 | +T["cursor does not enter zen side buffers"]["from top integration"] = function() |
| 71 | + child.cmd("Git") |
| 72 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "fugitive") |
| 73 | + |
| 74 | + child.cmd("wincmd j") |
| 75 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua") |
| 76 | + |
| 77 | + child.cmd("wincmd k") |
| 78 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "fugitive") |
| 79 | + |
| 80 | + child.cmd("wincmd h") |
| 81 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "fugitive") |
| 82 | + |
| 83 | + child.cmd("wincmd l") |
| 84 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "fugitive") |
| 85 | + |
| 86 | + child.cmd("close") |
| 87 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua") |
| 88 | +end |
| 89 | + |
| 90 | +T["cursor does not enter zen side buffers"]["from bottom integration"] = function() |
| 91 | + child.cmd("Trouble diagnostics open") |
| 92 | + child.cmd("wincmd j") |
| 93 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "trouble") |
| 94 | + |
| 95 | + child.cmd("wincmd k") |
| 96 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua") |
| 97 | + |
| 98 | + child.cmd("wincmd j") |
| 99 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "trouble") |
| 100 | + |
| 101 | + child.cmd("wincmd h") |
| 102 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "trouble") |
| 103 | + |
| 104 | + child.cmd("wincmd l") |
| 105 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "trouble") |
| 106 | + |
| 107 | + child.cmd("close") |
| 108 | + MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua") |
| 109 | +end |
| 110 | + |
| 111 | +return T |
0 commit comments