Merge branch 'main' into feat/color
This commit is contained in:
commit
8e0b2bdb6c
11 changed files with 441 additions and 172 deletions
|
|
@ -1,12 +1,15 @@
|
|||
describe('cp.cache', function()
|
||||
local cache
|
||||
local spec_helper = require('spec.spec_helper')
|
||||
|
||||
before_each(function()
|
||||
spec_helper.setup()
|
||||
cache = require('cp.cache')
|
||||
cache.load()
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
spec_helper.teardown()
|
||||
cache.clear_contest_data('atcoder', 'test_contest')
|
||||
cache.clear_contest_data('codeforces', 'test_contest')
|
||||
cache.clear_contest_data('cses', 'test_contest')
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
describe('cp.config', function()
|
||||
local config
|
||||
local spec_helper = require('spec.spec_helper')
|
||||
|
||||
before_each(function()
|
||||
spec_helper.setup()
|
||||
config = require('cp.config')
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
spec_helper.teardown()
|
||||
end)
|
||||
|
||||
describe('setup', function()
|
||||
it('returns defaults with nil input', function()
|
||||
local result = config.setup()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,15 @@
|
|||
describe('cp.diff', function()
|
||||
local diff = require('cp.diff')
|
||||
local spec_helper = require('spec.spec_helper')
|
||||
local diff
|
||||
|
||||
before_each(function()
|
||||
spec_helper.setup()
|
||||
diff = require('cp.diff')
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
spec_helper.teardown()
|
||||
end)
|
||||
|
||||
describe('get_available_backends', function()
|
||||
it('returns vim and git backends', function()
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ describe('cp.execute', function()
|
|||
local execute
|
||||
local mock_system_calls
|
||||
local temp_files
|
||||
local spec_helper = require('spec.spec_helper')
|
||||
|
||||
before_each(function()
|
||||
spec_helper.setup()
|
||||
execute = require('cp.execute')
|
||||
mock_system_calls = {}
|
||||
temp_files = {}
|
||||
|
|
@ -60,6 +62,7 @@ describe('cp.execute', function()
|
|||
|
||||
after_each(function()
|
||||
vim.system = vim.system_original or vim.system
|
||||
spec_helper.teardown()
|
||||
temp_files = {}
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,15 @@
|
|||
describe('cp.highlight', function()
|
||||
local highlight = require('cp.highlight')
|
||||
local spec_helper = require('spec.spec_helper')
|
||||
local highlight
|
||||
|
||||
before_each(function()
|
||||
spec_helper.setup()
|
||||
highlight = require('cp.highlight')
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
spec_helper.teardown()
|
||||
end)
|
||||
|
||||
describe('parse_git_diff', function()
|
||||
it('skips git diff headers', function()
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
describe('cp.problem', function()
|
||||
local problem
|
||||
local spec_helper = require('spec.spec_helper')
|
||||
|
||||
before_each(function()
|
||||
spec_helper.setup()
|
||||
problem = require('cp.problem')
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
spec_helper.teardown()
|
||||
end)
|
||||
|
||||
describe('create_context', function()
|
||||
local base_config = {
|
||||
contests = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,14 @@
|
|||
describe('cp.test_render', function()
|
||||
describe('cp.run_render', function()
|
||||
local run_render = require('cp.run_render')
|
||||
local spec_helper = require('spec.spec_helper')
|
||||
|
||||
before_each(function()
|
||||
spec_helper.setup()
|
||||
end)
|
||||
|
||||
after_each(function()
|
||||
spec_helper.teardown()
|
||||
end)
|
||||
|
||||
describe('get_status_info', function()
|
||||
it('returns AC for pass status', function()
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ describe('cp.scrape', function()
|
|||
local mock_cache
|
||||
local mock_system_calls
|
||||
local temp_files
|
||||
local spec_helper = require('spec.spec_helper')
|
||||
|
||||
before_each(function()
|
||||
spec_helper.setup()
|
||||
temp_files = {}
|
||||
|
||||
mock_cache = {
|
||||
|
|
@ -85,6 +87,7 @@ describe('cp.scrape', function()
|
|||
after_each(function()
|
||||
package.loaded['cp.cache'] = nil
|
||||
vim.system = vim.system_original or vim.system
|
||||
spec_helper.teardown()
|
||||
temp_files = {}
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
describe('cp.snippets', function()
|
||||
local snippets
|
||||
local mock_luasnip
|
||||
local spec_helper = require('spec.spec_helper')
|
||||
|
||||
before_each(function()
|
||||
spec_helper.setup()
|
||||
package.loaded['cp.snippets'] = nil
|
||||
snippets = require('cp.snippets')
|
||||
mock_luasnip = {
|
||||
snippet = function(trigger, body)
|
||||
|
|
@ -31,6 +34,8 @@ describe('cp.snippets', function()
|
|||
end)
|
||||
|
||||
after_each(function()
|
||||
spec_helper.teardown()
|
||||
package.loaded['cp.snippets'] = nil
|
||||
package.loaded['luasnip'] = nil
|
||||
package.loaded['luasnip.extras.fmt'] = nil
|
||||
end)
|
||||
|
|
|
|||
14
spec/spec_helper.lua
Normal file
14
spec/spec_helper.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
package.loaded['cp.log'] = {
|
||||
log = function() end,
|
||||
set_config = function() end,
|
||||
}
|
||||
end
|
||||
|
||||
function M.teardown()
|
||||
package.loaded['cp.log'] = nil
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
Add table
Add a link
Reference in a new issue