maxmx03.solarized.nvim/tests/setup_spec.lua
Max Miliano 3ae785b553 fix: prevent error when user pass a nil value to setup
added more tests and makefile
2024-09-19 10:39:43 -03:00

73 lines
1.7 KiB
Lua

local nvim_get_hl = require('solarized.utils').nvim_get_hl
describe('solarized.setup', function()
setup(function()
vim.o.background = 'light'
---@type solarized
local solarized = require 'solarized'
solarized.setup {
transparent = {
enabled = true,
},
styles = {
strings = { italic = true },
comments = { bold = true },
},
on_colors = function()
return {
mycolor = '#ffffff',
}
end,
on_highlights = function(colors)
return {
---@diagnostic disable-next-line: undefined-field
CustomHighlight = { fg = colors.mycolor },
}
end,
}
vim.cmd 'colorscheme solarized'
end)
test('transparent', function()
local normal = nvim_get_hl 'Normal'
assert.falsy(normal.bg)
end)
test('on_colors and on_highlight', function()
local user_group = nvim_get_hl 'CustomHighlight'
local expected = { fg = '#FFFFFF' }
assert.are.same(expected, user_group)
end)
test('styles', function()
local strings = nvim_get_hl 'String'
local comments = nvim_get_hl 'Comment'
assert.True(strings.italic)
assert.True(comments.bold)
end)
test('styles.enabled', function()
local solarized = require 'solarized'
solarized.setup {
styles = {
enabled = false,
strings = { italic = true },
comments = { bold = true },
},
}
vim.cmd 'colorscheme solarized'
local strings = nvim_get_hl 'String'
local comments = nvim_get_hl 'Comment'
assert.Nil(strings.italic)
assert.Nil(comments.bold)
end)
test('nil config', function()
local solarized = require 'solarized'
solarized.setup()
vim.cmd 'colorscheme solarized'
end)
end)