-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_text_actions.lua
More file actions
56 lines (48 loc) · 1.64 KB
/
test_text_actions.lua
File metadata and controls
56 lines (48 loc) · 1.64 KB
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
-- Define helper aliases
local new_set = MiniTest.new_set
local expect, eq = MiniTest.expect, MiniTest.expect.equality
-- Create (but not start) child Neovim object
local child = MiniTest.new_child_neovim()
-- Define main test set of this file
local T = new_set({
-- Register hooks
hooks = {
-- This will be executed before every (even nested) case
pre_case = function()
-- Restart child process with custom 'init.lua' script
child.restart({ "-u", "scripts/minimal_init.lua" })
-- Load tested plugin
child.lua([[require('python').setup()]])
end,
-- This will be executed one after all tests from this set are finished
post_once = child.stop,
},
})
local get_lines = function()
return child.api.nvim_buf_get_lines(0, 0, -1, true)
end
T["f-string"] = MiniTest.new_set({
hooks = {
pre_case = function()
child.cmd("e _not_existing_new_buffer.py")
child.type_keys("cc", [["TEST"]], "<Esc>", "0")
end,
},
})
T["f-string"]["insert f string"] = function()
child.cmd("e! _not_existing_new_buffer.py")
child.type_keys("cc", [["{foo}"]], "<Esc>", "hh", "i", "<Esc>")
eq(get_lines(), { [[f"{foo}"]] })
end
T["f-string"]["skip on r"] = function()
child.cmd("e! _not_existing_new_buffer.py")
child.type_keys("cc", [[r"{foo}"]], "<Esc>", "hh", "i", "<Esc>")
eq(get_lines(), { [[r"{foo}"]] })
end
T["f-string"]["skip on format"] = function()
child.cmd("e! _not_existing_new_buffer.py")
child.type_keys("cc", [["{foo}".format()]], "<Esc>", "0lll", "i", "<Esc>")
eq(get_lines(), { [["{foo}".format()]] })
end
-- Return test set which will be collected and execute inside `MiniTest.run()`
return T