mirror of
https://github.com/neovim/neovim.git
synced 2025-12-11 17:12:40 +00:00
refactor: deduplicate test
This commit is contained in:
@@ -39,35 +39,23 @@ describe('vim.net.request', function()
|
|||||||
)
|
)
|
||||||
end)
|
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')
|
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! plugin/nvim/net.lua')
|
||||||
vim.cmd('runtime! filetype.lua')
|
vim.cmd('runtime! filetype.lua')
|
||||||
-- github raw dump of a small lua file in the neovim repo
|
-- 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.cmd('edit https://raw.githubusercontent.com/neovim/neovim/master/runtime/syntax/tutor.lua')
|
||||||
vim.wait(2000, function() return vim.bo.filetype ~= '' end)
|
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
|
-- wait for buffer to have content
|
||||||
vim.wait(2000, function() return vim.fn.wordcount().bytes > 0 end)
|
vim.wait(2000, function() return vim.fn.wordcount().bytes > 0 end)
|
||||||
vim.wait(2000, function() return vim.bo.modified == false 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)
|
end)
|
||||||
|
|
||||||
it('calls on_response with error on 404 (async failure)', function()
|
it('calls on_response with error on 404 (async failure)', function()
|
||||||
|
|||||||
Reference in New Issue
Block a user