Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update unit tests #245

Merged
merged 6 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
matrix:
include:
- os: ubuntu-latest
url: https://github.com/neovim/neovim/releases/download/v0.7.0/nvim-linux64.tar.gz
url: https://github.com/neovim/neovim/releases/download/v0.10.1/nvim-linux64.tar.gz
- os: macos-latest
url: https://github.com/neovim/neovim/releases/download/v0.7.0/nvim-macos.tar.gz
url: https://github.com/neovim/neovim/releases/download/v0.10.1/nvim-macos-arm64.tar.gz
steps:
- uses: actions/checkout@v3
- name: Prepare
Expand Down
8 changes: 3 additions & 5 deletions test/spec/automated/install_spec.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
local install = require 'scnvim.install'

local is_ci = vim.loop.os_getenv 'SCNVIM_CI'
if is_ci then
require('scnvim.path').get_plugin_root_dir = function()
return vim.fn.expand '%:p:h:h'
end
-- override for unit test runner
require('scnvim.path').get_plugin_root_dir = function()
return vim.fn.expand '%:p:h:h'
end

describe('install', function()
Expand Down
3 changes: 2 additions & 1 deletion test/spec/automated/map_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ describe('map', function()
cb(lines)
end
end)
vim.api.nvim_buf_set_lines(0, -2, -1, false, { 'foo' })
vim.api.nvim_win_set_cursor(0, { 1, 0 })
vim.api.nvim_buf_set_lines(0, -2, -1, true, { 'foo' })
ret.fn()
editor.on_send:restore()
end)
Expand Down
18 changes: 7 additions & 11 deletions test/spec/automated/path_spec.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
local path = require 'scnvim.path'

local eq = assert.are.same
local is_ci = vim.loop.os_getenv 'SCNVIM_CI'
if is_ci then
path.get_plugin_root_dir = function()
return vim.fn.expand '%:p:h:h'
end

-- override for unit test runner
path.get_plugin_root_dir = function()
return vim.fn.expand '%:p:h:h'
end

describe('path', function()
Expand Down Expand Up @@ -73,9 +71,7 @@ describe('path', function()
assert.is_false(path.exists(destination))
end)

it('returns plugin root dir', function()
local root_dir = path.get_plugin_root_dir()
root_dir = string.match(root_dir, 'scnvim')
eq(root_dir, 'scnvim')
end)
-- TODO: Find another way to test this function
-- it('returns plugin root dir', function()
-- end)
end)
4 changes: 2 additions & 2 deletions test/spec/automated/postwin_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ describe('post window', function()
}
local id = postwin.open()
local cfg = vim.api.nvim_win_get_config(id)
assert.are.equal(3, cfg.row[true])
assert.are.equal(3, cfg.col[true])
assert.are.equal(3, cfg.row)
assert.are.equal(3, cfg.col)
assert.are.equal(12, cfg.width)
assert.are.equal(12, cfg.height)
assert.are.equal('NW', cfg.anchor)
Expand Down
Loading