refactor: deduplicate test

This commit is contained in:
Justin M. Keyes
2025-11-20 01:11:17 -05:00
parent 4bbdffe829
commit 83d22e0979

View File

@@ -39,35 +39,23 @@ describe('vim.net.request', function()
)
end)
it('detects filetype for remote content', function()
it("detects filetype, sets 'nomodified'", function()
t.skip(skip_integ, 'NVIM_TEST_INTEG not set: skipping network integration test')
local ft = exec_lua([[
local rv = exec_lua([[
vim.cmd('runtime! plugin/nvim/net.lua')
vim.cmd('runtime! filetype.lua')
-- github raw dump of a small lua file in the neovim repo
vim.cmd('edit https://raw.githubusercontent.com/neovim/neovim/master/runtime/syntax/tutor.lua')
vim.wait(2000, function() return vim.bo.filetype ~= '' end)
return vim.bo.filetype
]])
assert(ft == 'lua', 'Expected filetype to be "lua", got: ' .. tostring(ft))
end)
it('removes the modified flag from the buffer for remote content', function()
t.skip(skip_integ, 'NVIM_TEST_INTEG not set: skipping network integration test')
local buffer_modified = exec_lua([[
vim.cmd('runtime! plugin/nvim/net.lua')
vim.cmd('runtime! filetype.lua')
vim.cmd('edit https://raw.githubusercontent.com/neovim/neovim/master/runtime/syntax/tutor.lua')
-- wait for buffer to have content
vim.wait(2000, function() return vim.fn.wordcount().bytes > 0 end)
vim.wait(2000, function() return vim.bo.modified == false end)
return vim.bo.modified
return { vim.bo.filetype, vim.bo.modified }
]])
assert(not buffer_modified, 'Expected buffer to be unmodified for remote content')
t.eq('lua', rv[1])
t.eq(false, rv[2], 'Expected buffer to be unmodified for remote content')
end)
it('calls on_response with error on 404 (async failure)', function()