mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
* I did an overhall for all codes and added typing by Lua-language-server and tests. It also works on CI. * Now it searches files on the workspace completely asynchronously. It does not block your text input. (Fix #106) Make count = 1 when you open a file you've never opened (Fix #107)
20 lines
855 B
Lua
20 lines
855 B
Lua
local Recency = require "frecency.recency"
|
|
local recency = Recency.new()
|
|
|
|
describe("frecency.recency", function()
|
|
for _, c in ipairs {
|
|
{ count = 1, ages = { 200 }, score = 10 },
|
|
{ count = 2, ages = { 200, 1000 }, score = 36 },
|
|
{ count = 3, ages = { 200, 1000, 4000 }, score = 72 },
|
|
{ count = 4, ages = { 200, 1000, 4000, 10000 }, score = 112 },
|
|
{ count = 5, ages = { 200, 1000, 4000, 10000, 40000 }, score = 150 },
|
|
{ count = 6, ages = { 200, 1000, 4000, 10000, 40000, 100000 }, score = 186 },
|
|
{ count = 86, ages = { 11770, 11769, 11431, 5765, 3417, 3398, 3378, 134, 130, 9 }, score = 4988 },
|
|
} do
|
|
local dumped = vim.inspect(c.ages, { indent = "", newline = "" })
|
|
it(("%d, %s => %d"):format(c.count, dumped, c.score), function()
|
|
assert.are.same(c.score, recency:calculate(c.count, c.ages))
|
|
end)
|
|
end
|
|
end)
|