๐Ÿ“ฆ SergioRibera / codeshot.nvim

๐Ÿ“„ theme_spec.lua ยท 60 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60local theme = require('codeshot.theme')

describe('Generate Args', function()
  it('Test theme from object', function()
    local default = {
      LineNr = { fg = '#fff', bg = '#323232' },
      Normal = { fg = '#fff', bg = '#323232' },
      Visual = { fg = '#fff', bg = '#323232' },
    }
    assert.are.same(theme.get(default), 'LineNr,#323232,#fff,;Normal,#323232,#fff,;Visual,#323232,#fff,;')
  end)

  it('Test generate hl from object', function()
    local default = {
      background = 2500134,
      foreground = 14334359,
    }
    assert.are.same(theme._gen_hl(default), {
      fg = '#dab997',
      bg = '#262626',
      style = '',
    })
  end)

  it('Test generate hl from incomplete object', function()
    local default = {
      background = 2500134,
    }
    assert.are.same(theme._gen_hl(default), {
      fg = '',
      bg = '#262626',
      style = '',
    })
  end)

  it('Test generate hl object with style', function()
    local default = {
      background = 2500134,
      underline = true,
    }
    assert.are.same(theme._gen_hl(default), {
      fg = '',
      bg = '#262626',
      style = 'underline',
    })
  end)

  it('Test theme from object with style', function()
    local default = {
      LineNr = { fg = '#fff', bg = '#323232', style = 'underline' },
      Normal = { fg = '#fff', bg = '#323232', style = 'bold' },
      Visual = { fg = '#fff', bg = '#323232', style = 'undercurl' },
    }
    assert.are.same(
      theme.get(default),
      'LineNr,#323232,#fff,underline;Normal,#323232,#fff,bold;Visual,#323232,#fff,undercurl;'
    )
  end)
end)