diff --git a/CHANGELOG.md b/CHANGELOG.md index 62377c7..ac95706 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic ### Issues Fix - Made `Color()` constructor idempotent (previously, passing a `Color` inst silently caused a bug) +- Fixed unable to override/customize spec (#359) ## [v1.1.0] - 23 July 2024 diff --git a/test/github-theme/config/overrides_spec.lua b/test/github-theme/config/overrides_spec.lua index d9b7fb7..8b7df93 100644 --- a/test/github-theme/config/overrides_spec.lua +++ b/test/github-theme/config/overrides_spec.lua @@ -23,6 +23,7 @@ describe('config > groups', function() all = { Normal = { fg = '#123456', bg = '#654321' } }, }, }) + vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } }) assert.same({}, t_util.get_hl('Normal')) end) @@ -30,10 +31,11 @@ describe('config > groups', function() it('clearing group combines properly with more-specific overrides', function() require('github-theme').setup({ groups = { - all = { Normal = {} }, github_dark_dimmed = { Normal = { fg = '#123456', bg = '#654321' } }, + all = { Normal = {} }, }, }) + vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } }) assert.same( { fg = tonumber('123456', 16), bg = tonumber('654321', 16) }, @@ -45,6 +47,7 @@ describe('config > groups', function() require('github-theme').setup({ groups = { all = { Normal = { fg = '#123456', bg = '#654321' } } }, }) + vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } }) assert.same( { fg = tonumber('123456', 16), bg = tonumber('654321', 16) }, @@ -55,10 +58,11 @@ describe('config > groups', function() it('overriding group combines properly with more-specific overrides (1)', function() require('github-theme').setup({ groups = { - all = { Normal = { link = 'NormalNC' } }, github_dark_dimmed = { Normal = { fg = '#123456', bg = '#654321' } }, + all = { Normal = { link = 'NormalNC' } }, }, }) + vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } }) assert.is_nil(t_util.get_hl('Normal', true).link) end) @@ -66,10 +70,11 @@ describe('config > groups', function() it('overriding group combines properly with more-specific overrides (2)', function() require('github-theme').setup({ groups = { - all = { Normal = { fg = '#123456', bg = '#654321' } }, github_dark_dimmed = { Normal = { link = 'NormalNC' } }, + all = { Normal = { fg = '#123456', bg = '#654321' } }, }, }) + vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } }) assert.same({ link = 'NormalNC' }, t_util.get_hl('Normal', true)) end) @@ -78,6 +83,7 @@ describe('config > groups', function() require('github-theme').setup({ groups = { all = { Normal = { link = 'NormalNC' } } }, }) + vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } }) assert.same({ link = 'NormalNC' }, t_util.get_hl('Normal', true)) end) @@ -106,3 +112,25 @@ describe('config > groups', function() ) end) end) + +describe('config > specs', function() + before_each(function() + require('github-theme.util.reload')(true) + end) + + it('should allow overriding the spec', function() + require('github-theme').setup({ + specs = { + github_dark_dimmed = { bg1 = '#654321' }, + github_dark = { bg1 = '#652322' }, + all = { bg1 = '#123456' }, + }, + }) + + local spec = require('github-theme.spec').load('github_dark_dimmed') + assert.equals('#654321', spec.bg1) + + vim.cmd.colorscheme({ args = { 'github_dark_dimmed' } }) + assert.same(tonumber('654321', 16), t_util.get_hl('Normal').bg) + end) +end)