fix(ci): typing
This commit is contained in:
parent
87f9439607
commit
eb3f7762de
9 changed files with 339 additions and 155 deletions
|
|
@ -158,9 +158,7 @@ describe('cp.picker', function()
|
|||
end,
|
||||
}
|
||||
|
||||
package.loaded['cp.pickers.init'] = nil
|
||||
package.loaded['cp.pickers'] = nil
|
||||
picker = require('cp.pickers')
|
||||
picker = spec_helper.fresh_require('cp.pickers', { 'cp.pickers.init' })
|
||||
|
||||
local problems = picker.get_problems_for_contest('test_platform', 'test_contest')
|
||||
assert.is_table(problems)
|
||||
|
|
@ -183,6 +181,8 @@ describe('cp.picker', function()
|
|||
}
|
||||
end
|
||||
|
||||
picker = spec_helper.fresh_require('cp.pickers', { 'cp.pickers.init' })
|
||||
|
||||
local problems = picker.get_problems_for_contest('test_platform', 'test_contest')
|
||||
assert.is_table(problems)
|
||||
assert.equals(0, #problems)
|
||||
|
|
|
|||
|
|
@ -56,8 +56,7 @@ describe('cp.scrape', function()
|
|||
|
||||
package.loaded['cp.cache'] = mock_cache
|
||||
package.loaded['cp.utils'] = mock_utils
|
||||
package.loaded['cp.scrape'] = nil
|
||||
scrape = require('cp.scrape')
|
||||
scrape = spec_helper.fresh_require('cp.scrape')
|
||||
|
||||
local original_fn = vim.fn
|
||||
vim.fn = vim.tbl_extend('force', vim.fn, {
|
||||
|
|
@ -125,8 +124,7 @@ describe('cp.scrape', function()
|
|||
stored_data = { platform = platform, contest_id = contest_id, problems = problems }
|
||||
end
|
||||
|
||||
package.loaded['cp.scrape'] = nil
|
||||
scrape = require('cp.scrape')
|
||||
scrape = spec_helper.fresh_require('cp.scrape')
|
||||
|
||||
local result = scrape.scrape_contest_metadata('atcoder', 'abc123')
|
||||
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@ describe('cp.snippets', function()
|
|||
|
||||
before_each(function()
|
||||
spec_helper.setup()
|
||||
package.loaded['cp.snippets'] = nil
|
||||
snippets = require('cp.snippets')
|
||||
snippets = spec_helper.fresh_require('cp.snippets')
|
||||
mock_luasnip = {
|
||||
snippet = function(trigger, body)
|
||||
return { trigger = trigger, body = body }
|
||||
|
|
|
|||
|
|
@ -121,6 +121,17 @@ function M.find_logged_message(pattern)
|
|||
return nil
|
||||
end
|
||||
|
||||
function M.fresh_require(module_name, additional_clears)
|
||||
additional_clears = additional_clears or {}
|
||||
|
||||
for _, clear_module in ipairs(additional_clears) do
|
||||
package.loaded[clear_module] = nil
|
||||
end
|
||||
package.loaded[module_name] = nil
|
||||
|
||||
return require(module_name)
|
||||
end
|
||||
|
||||
function M.teardown()
|
||||
package.loaded['cp.log'] = nil
|
||||
package.loaded['cp.scrape'] = nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue