|
| 1 | +local assert = require('luassert') |
| 2 | +local t_util = require('github-theme._test.util') |
| 3 | +local C = require('github-theme.lib.color') |
| 4 | +local api = vim.api |
| 5 | + |
| 6 | +if not api.nvim_get_hl then |
| 7 | + return |
| 8 | +end |
| 9 | + |
| 10 | +describe('config > options > darken', function() |
| 11 | + before_each(function() |
| 12 | + require('github-theme.config').reset() |
| 13 | + end) |
| 14 | + |
| 15 | + describe('> floats', function() |
| 16 | + for _, variant in ipairs(require('github-theme.palette').themes) do |
| 17 | + -- TODO: see #324 |
| 18 | + local _it = variant:find('high[-_]*contrast') and pending or it |
| 19 | + |
| 20 | + _it(('should be enabled by default (%s)'):format(variant), function() |
| 21 | + require('github-theme').setup() |
| 22 | + vim.cmd.colorscheme({ args = { variant } }) |
| 23 | + local normal_float = t_util.get_hl('NormalFloat') |
| 24 | + local normal = t_util.get_hl('Normal') |
| 25 | + |
| 26 | + assert.is_true(require('github-theme.config').options.darken.floats) |
| 27 | + assert.are.not_equal(normal_float.bg, normal.bg) |
| 28 | + assert( |
| 29 | + C(('#%x'):format(normal_float.bg)):luminance() |
| 30 | + < C(('#%x'):format(normal.bg)):luminance(), |
| 31 | + ('expected `bg` of `NormalFloat` (#%x) to be darker than `bg` of `Normal` (#%x)'):format( |
| 32 | + normal_float.bg, |
| 33 | + normal.bg |
| 34 | + ) |
| 35 | + ) |
| 36 | + end) |
| 37 | + |
| 38 | + it(('should be disabled when set to `false` (%s)'):format(variant), function() |
| 39 | + require('github-theme').setup({ options = { darken = { floats = false } } }) |
| 40 | + vim.cmd.colorscheme({ args = { variant } }) |
| 41 | + local normal_float = t_util.get_hl('NormalFloat') |
| 42 | + local normal = t_util.get_hl('Normal') |
| 43 | + |
| 44 | + assert.is_false(require('github-theme.config').options.darken.floats) |
| 45 | + assert.are.equal(normal_float.bg, normal.bg) |
| 46 | + end) |
| 47 | + end |
| 48 | + end) |
| 49 | +end) |
0 commit comments