-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgolden_size_spec.lua
60 lines (47 loc) · 1.71 KB
/
golden_size_spec.lua
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
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local nvim = helpers.nvim
local clear, command = helpers.clear, helpers.command
local alter_slashes = helpers.alter_slashes
local eq = helpers.eq
describe('golden size', function()
local screen
local screen_width = 80
local plugin_dir = os.getenv("TEST_FILE"):match("(.*/)")
before_each(function()
clear()
screen = Screen.new(screen_width, 20)
screen:attach()
command('set rtp+=' .. alter_slashes(plugin_dir))
command('source ' .. alter_slashes(plugin_dir .. 'plugin/golden_size.vim'))
end)
after_each(function()
screen:detach()
end)
it('resizes the active window to "golden" size', function()
local expected_width = math.floor(screen_width / 1.618)
eq(nvim('win_get_width', 0), screen_width)
command('vsp')
eq(nvim('win_get_width', 0), expected_width)
end)
function open_float_win(opts)
local buf = nvim('create_buf', false, true)
nvim('buf_set_lines', buf, 0, -1, true, {"test"})
local opts = {relative='win', width=opts['width'], height=10, col=0, row=1}
local win = nvim('open_win', buf, 0, opts)
return win
end
it('does not resize float windows', function()
local expected_width = 10
local float_win = open_float_win({width = expected_width})
nvim('set_current_win', float_win)
eq(nvim('win_get_width', 0), expected_width)
end)
it('allows to set custom ignore callbacks', function()
command('lua function ignore_all() return 1 end')
command('lua golden_size.set_ignore_callbacks({ { ignore_all } })')
command('vsp')
local default_width_after_split = screen_width / 2
eq(nvim('win_get_width', 0), default_width_after_split)
end)
end)