Skip to content

Commit

Permalink
test: add rudimentary smoke tests to check for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tmillr committed Sep 21, 2023
1 parent e00c67b commit da1edb8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lua/github-theme/_test/util.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local M = {}
local api = vim.api

function M.await_VimEnter()
if vim.v.vim_did_enter == 0 then
local co = assert(coroutine.running(), 'test is not running in coroutine')

api.nvim_create_autocmd('VimEnter', {
pattern = '*',
once = true,
nested = true,
callback = vim.schedule_wrap(function()
coroutine.resume(co)
end),
})

coroutine.yield()
end
end

return M
33 changes: 33 additions & 0 deletions test/github-theme/smoketest/startup_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
local assert = require('luassert')
local t_util = require('github-theme._test.util')

describe('(smoke test)', function()
describe('setting colorscheme during startup', function()
it('should not error', function()
assert.does_not_error(function()
vim.cmd('colorscheme github_dark_dimmed')
end)

assert.is.equal('', vim.v.errmsg or '')
end)
end)

describe('setting/switching colorscheme post-startup', function()
it('should not error', function()
t_util.await_VimEnter()

for _, cs in ipairs({
'default',
'github_dark_dimmed',
'github_dark_dimmed',
'github_light',
}) do
assert.does_not_error(function()
vim.cmd('colorscheme ' .. cs)
end)

assert.is.equal('', vim.v.errmsg or '')
end
end)
end)
end)

0 comments on commit da1edb8

Please sign in to comment.