aboutsummaryrefslogtreecommitdiff
path: root/dot_config/herdr/plugins/github/herdr-splits-d880c4924f2b/tests/test_plugin.lua
blob: 0afc9295e33d59a441e3be5e0e642938ffbda0e0 (plain) (blame)
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 T
local expect = MiniTest.expect
local child = MiniTest.new_child_neovim()

local source = debug.getinfo(1, 'S').source
local root = vim.fn.fnamemodify(source:sub(2), ':p:h:h')

T = MiniTest.new_set({
  hooks = {
    pre_case = function()
      child.restart({ '--noplugin', '-u', 'NONE', '-i', 'NONE' })
      child.cmd('set runtimepath^=' .. vim.fn.fnameescape(root))
    end,
    post_case = function()
      child.stop()
    end,
  },
})

T['public module loads its expected API'] = function()
  local result = child.lua_func(function()
    local plugin = require('herdr-splits')
    local names = {
      'setup',
      'sync_herdr',
      'resize_left',
      'resize_down',
      'resize_up',
      'resize_right',
      'move_cursor_left',
      'move_cursor_down',
      'move_cursor_up',
      'move_cursor_right',
      'add_ignored_filetype',
      'add_ignored_buftype',
    }
    local types = {}
    for _, name in ipairs(names) do
      types[name] = type(plugin[name])
    end
    return types
  end)

  expect.equality(result, {
    setup = 'function',
    sync_herdr = 'function',
    resize_left = 'function',
    resize_down = 'function',
    resize_up = 'function',
    resize_right = 'function',
    move_cursor_left = 'function',
    move_cursor_down = 'function',
    move_cursor_up = 'function',
    move_cursor_right = 'function',
    add_ignored_filetype = 'function',
    add_ignored_buftype = 'function',
  })
end

return T