Skip to content

Commit

Permalink
test: add config specs
Browse files Browse the repository at this point in the history
  • Loading branch information
2KAbhishek committed Nov 22, 2024
1 parent d7350e4 commit ee441d6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 14 deletions.
55 changes: 55 additions & 0 deletions tests/config_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
local config = require('exercism.config')

describe('exercism.config', function()
local default_config = {
exercism_workspace = '~/exercism',
default_language = 'ruby',
add_default_keybindings = true,
icons = {
concept = '',
practice = '',
},
}

before_each(function()
config.setup(vim.deepcopy(default_config))
end)

it('has default values', function()
assert.are.same(config.config.exercism_workspace, '~/exercism')
assert.are.same(config.config.default_language, 'ruby')
assert.are.same(config.config.add_default_keybindings, true)
assert.are.same(config.config.icons.concept, '')
assert.are.same(config.config.icons.practice, '')
end)

it('can be overridden', function()
local new_config = {
exercism_workspace = '~/my_exercism',
default_language = 'python',
add_default_keybindings = false,
icons = {
concept = '',
practice = '',
},
}
config.setup(new_config)
assert.are.same(config.config.exercism_workspace, '~/my_exercism')
assert.are.same(config.config.default_language, 'python')
assert.are.same(config.config.add_default_keybindings, false)
assert.are.same(config.config.icons.concept, '')
assert.are.same(config.config.icons.practice, '')
end)

it('merges partial overrides', function()
local partial_config = {
default_language = 'go',
}
config.setup(partial_config)
assert.are.same(config.config.exercism_workspace, '~/exercism')
assert.are.same(config.config.default_language, 'go')
assert.are.same(config.config.add_default_keybindings, true)
assert.are.same(config.config.icons.concept, '')
assert.are.same(config.config.icons.practice, '')
end)
end)
14 changes: 0 additions & 14 deletions tests/main_spec.lua

This file was deleted.

0 comments on commit ee441d6

Please sign in to comment.