Skip to content

Commit 4bb9f1a

Browse files
authored
chore: add more tests (#75)
1 parent 5020d1a commit 4bb9f1a

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

tests/spec/color_spec.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,23 @@ describe("Override config with color utility", function()
1919

2020
assert.equal("#41143a", ("#%06x"):format(hl.fg))
2121
end)
22+
23+
it("could use lighten utility", function()
24+
local expected = {
25+
colors = {
26+
lmao = "#812873",
27+
},
28+
themes = function(c)
29+
return {
30+
Normal = { fg = c.lmao:lighten(0.5) },
31+
}
32+
end,
33+
}
34+
35+
one_monokai.setup(expected)
36+
37+
local hl = vim.api.nvim_get_hl(0, { name = "Normal" })
38+
39+
assert.equal("#c094b9", ("#%06x"):format(hl.fg))
40+
end)
2241
end)

tests/spec/config_spec.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,36 @@ describe("Override config", function()
5252
assert.is_nil(paremeter_hl.italic)
5353
end)
5454
end)
55+
56+
describe("Override wrong config", function()
57+
local wrong_opts = {
58+
colors = {
59+
aqua = true,
60+
},
61+
themes = function()
62+
return {
63+
Normal = { fg = "lmao", italic = true },
64+
}
65+
end,
66+
}
67+
68+
local colors_pre = require "one_monokai.colors"
69+
70+
one_monokai.setup(wrong_opts)
71+
72+
package.loaded["one_monokai.colors"] = nil
73+
74+
it("should fallback to default colors", function()
75+
local colors_post = require "one_monokai.colors"
76+
77+
assert.are.same(colors_pre.aqua, colors_post.aqua)
78+
end)
79+
80+
it("should fallback to default highlights", function()
81+
local default = require "one_monokai.themes.groups"
82+
local hl = vim.api.nvim_get_hl(0, { name = "Normal" })
83+
84+
assert.equal(default.Normal.fg, ("#%06x"):format(hl.fg))
85+
assert.is_nil(hl.italic)
86+
end)
87+
end)

0 commit comments

Comments
 (0)