Repository: neovim/neovim
File: test/functional/plugin/health_spec.lua (Lua)

Code before:
      'test_plug.success1',
      'test_plug.success2',
    }, getcompletion('test_plug', 'checkhealth'))
  end)

  it('completion checks for vim.health._complete() return type #28456', function()
    clear()
    exec_lua([[vim.health._complete = function() return 1 end]])
    eq({}, getcompletion('', 'checkhealth'))
    exec_lua([[vim.health._complete = function() return { 1 } end]])
    eq({}, getcompletion('', 'checkhealth'))
    assert_alive()
  end)

  it('vim.g.health', function()
    clear { args = { '-u', 'NORC', '+set runtimepath+=test/functional/fixtures' } }
    command("let g:health = {'style':'float'}")
    command('checkhealth lsp')
    eq(
      'editor',
      exec_lua([[
      return vim.api.nvim_win_get_config(0).relative
    ]])
    )

    -- Prevent checkhealth floating window after using gO. See #34784
    command('checkhealth full_render')
    local win = api.nvim_get_current_win()
    api.nvim_win_set_cursor(win, { 5, 1 })
    n.feed('gO')
    eq(true, api.nvim_win_is_valid(win))
    eq('qf', api.nvim_get_option_value('filetype', { buf = 0 }))
  end)

  it("vim.provider works with a misconfigured 'shell'", function()
    clear()
    command([[set shell=echo\ WRONG!!!]])
    command('let g:loaded_perl_provider = 0')
    command('let g:loaded_python3_provider = 0')
    command('checkhealth vim.provider')
    eq(nil, string.match(curbuf_contents(), 'WRONG!!!'))
  end)
end)

describe('vim.health', function()
  before_each(function()
    clear { args = { '-u', 'NORC', '+set runtimepath+=test/functional/fixtures' } }
  end)

  describe(':checkhealth', function()
    it('report_xx() renders correctly', function()

Review comment (suggestion):
```suggestion
    -- Prevent checkhealth floating window closing after using gO. See #34784
```

Code after:
      'test_plug.success1',
      'test_plug.success2',
    }, getcompletion('test_plug', 'checkhealth'))
  end)

  it('completion checks for vim.health._complete() return type #28456', function()
    clear()
    exec_lua([[vim.health._complete = function() return 1 end]])
    eq({}, getcompletion('', 'checkhealth'))
    exec_lua([[vim.health._complete = function() return { 1 } end]])
    eq({}, getcompletion('', 'checkhealth'))
    assert_alive()
  end)

  it('vim.g.health', function()
    clear {
      args_rm = { '-u' },
      args = { '--clean', '+set runtimepath+=test/functional/fixtures' },
    }
    command("let g:health = {'style':'float'}")
    command('checkhealth lsp')
    eq(
      'editor',
      exec_lua([[
      return vim.api.nvim_win_get_config(0).relative
    ]])
    )

    -- gO should not close the :checkhealth floating window. #34784
    command('checkhealth full_render')
    local win = api.nvim_get_current_win()
    api.nvim_win_set_cursor(win, { 5, 1 })
    n.feed('gO')
    eq(true, api.nvim_win_is_valid(win))
    eq('qf', api.nvim_get_option_value('filetype', { buf = 0 }))
  end)

  it("vim.provider works with a misconfigured 'shell'", function()
    clear()
    command([[set shell=echo\ WRONG!!!]])
    command('let g:loaded_perl_provider = 0')
    command('let g:loaded_python3_provider = 0')
    command('checkhealth vim.provider')
    eq(nil, string.match(curbuf_contents(), 'WRONG!!!'))
  end)
end)

describe('vim.health', function()
  before_each(function()
    clear { args = { '-u', 'NORC', '+set runtimepath+=test/functional/fixtures' } }
  end)