Skip to content

Commit 18a0d2d

Browse files
committed
chore: migrate to busted api
1 parent cc7306e commit 18a0d2d

6 files changed

Lines changed: 557 additions & 586 deletions

File tree

‎tests/scripts/minimal_init.lua‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
vim.cmd([[let &rtp.=','.getcwd()]])
22
vim.opt.packpath:prepend("deps")
33

4-
require("mini.test").setup()
4+
require("mini.test").setup({
5+
collect = {
6+
emulate_busted = true,
7+
},
8+
})

‎tests/test_autocmd.lua‎

Lines changed: 53 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
local Helpers = dofile("tests/scripts/helpers.lua")
22
local child = MiniTest.new_child_neovim()
33

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()
4+
before_each(function()
5+
child.restart({ "-u", "tests/scripts/init_with_zen.lua" })
6+
end)
7+
8+
teardown(child.stop)
9+
10+
it("closes zen side buffers on last main quit", function()
1411
Helpers.expect.layout(child, {
1512
type = "row",
1613
children = {
@@ -25,9 +22,9 @@ T["close zen side buffers on last main quit"] = function()
2522
local STOPPED = 0
2623
local exit_code = vim.fn.jobwait({ child.job.id }, 1000)[1]
2724
MiniTest.expect.equality(exit_code, STOPPED)
28-
end
25+
end)
2926

30-
T["open zen side buffers on startup"] = function()
27+
it("opens zen side buffers on startup", function()
3128
Helpers.expect.layout(child, {
3229
type = "row",
3330
children = {
@@ -36,9 +33,9 @@ T["open zen side buffers on startup"] = function()
3633
{ type = "leaf", filetype = "zen-right", buftype = "nofile", width = 46, height = 50 },
3734
},
3835
})
39-
end
36+
end)
4037

41-
T["do not open zen side buffers when there is not enough space"] = function()
38+
it("does not open zen side buffers when there is not enough space", function()
4239
child.restart({ "-u", "tests/scripts/init_with_zen_small.lua" })
4340

4441
Helpers.expect.layout(child, {
@@ -48,64 +45,60 @@ T["do not open zen side buffers when there is not enough space"] = function()
4845
width = 140,
4946
height = 50,
5047
})
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-
})
48+
end)
6149

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")
50+
describe("cursor does not enter zen side buffers", function()
51+
before_each(function()
52+
child.restart({ "-u", "tests/scripts/init_with_zen.lua" })
53+
child.cmd("edit test.lua")
54+
end)
6555

66-
child.cmd("wincmd l")
67-
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua")
68-
end
56+
it("from main", function()
57+
child.cmd("wincmd h")
58+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua")
6959

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")
60+
child.cmd("wincmd l")
61+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua")
62+
end)
7363

74-
child.cmd("wincmd j")
75-
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua")
64+
it("from top integration", function()
65+
child.cmd("Git")
66+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "fugitive")
7667

77-
child.cmd("wincmd k")
78-
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "fugitive")
68+
child.cmd("wincmd j")
69+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua")
7970

80-
child.cmd("wincmd h")
81-
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "fugitive")
71+
child.cmd("wincmd k")
72+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "fugitive")
8273

83-
child.cmd("wincmd l")
84-
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "fugitive")
74+
child.cmd("wincmd h")
75+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "fugitive")
8576

86-
child.cmd("close")
87-
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua")
88-
end
77+
child.cmd("wincmd l")
78+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "fugitive")
8979

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")
80+
child.cmd("close")
81+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua")
82+
end)
9483

95-
child.cmd("wincmd k")
96-
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua")
84+
it("from bottom integration", function()
85+
child.cmd("Trouble diagnostics open")
86+
child.cmd("wincmd j")
87+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "trouble")
9788

98-
child.cmd("wincmd j")
99-
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "trouble")
89+
child.cmd("wincmd k")
90+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua")
10091

101-
child.cmd("wincmd h")
102-
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "trouble")
92+
child.cmd("wincmd j")
93+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "trouble")
10394

104-
child.cmd("wincmd l")
105-
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "trouble")
95+
child.cmd("wincmd h")
96+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "trouble")
10697

107-
child.cmd("close")
108-
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua")
109-
end
98+
child.cmd("wincmd l")
99+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "trouble")
110100

111-
return T
101+
child.cmd("close")
102+
MiniTest.expect.equality(child.lua_get("vim.bo.filetype"), "lua")
103+
end)
104+
end)

0 commit comments

Comments
 (0)