Merge remote-tracking branch 'origin/main' into docs/sync-s3-auto-auth
This commit is contained in:
commit
8abb7393fc
5 changed files with 127 additions and 2 deletions
|
|
@ -275,6 +275,98 @@ describe('diff', function()
|
|||
assert.are.equal('completion', tasks[1].recur_mode)
|
||||
end)
|
||||
|
||||
it('returns forge refs for new tasks', function()
|
||||
local lines = {
|
||||
'# Inbox',
|
||||
'- [ ] Fix bug gh:user/repo#42',
|
||||
}
|
||||
local refs = diff.apply(lines, s)
|
||||
assert.are.equal(1, #refs)
|
||||
assert.are.equal('github', refs[1].forge)
|
||||
assert.are.equal(42, refs[1].number)
|
||||
end)
|
||||
|
||||
it('returns forge refs for changed refs on existing tasks', function()
|
||||
s:add({
|
||||
description = 'Fix bug gh:user/repo#1',
|
||||
_extra = {
|
||||
_forge_ref = {
|
||||
forge = 'github',
|
||||
owner = 'user',
|
||||
repo = 'repo',
|
||||
type = 'issue',
|
||||
number = 1,
|
||||
url = '',
|
||||
},
|
||||
},
|
||||
})
|
||||
s:save()
|
||||
local lines = {
|
||||
'# Todo',
|
||||
'/1/- [ ] Fix bug gh:user/repo#99',
|
||||
}
|
||||
local refs = diff.apply(lines, s)
|
||||
assert.are.equal(1, #refs)
|
||||
assert.are.equal(99, refs[1].number)
|
||||
end)
|
||||
|
||||
it('returns empty when forge ref is unchanged', function()
|
||||
s:add({
|
||||
description = 'Fix bug gh:user/repo#42',
|
||||
_extra = {
|
||||
_forge_ref = {
|
||||
forge = 'github',
|
||||
owner = 'user',
|
||||
repo = 'repo',
|
||||
type = 'issue',
|
||||
number = 42,
|
||||
url = '',
|
||||
},
|
||||
},
|
||||
})
|
||||
s:save()
|
||||
local lines = {
|
||||
'# Todo',
|
||||
'/1/- [ ] Fix bug gh:user/repo#42',
|
||||
}
|
||||
local refs = diff.apply(lines, s)
|
||||
assert.are.equal(0, #refs)
|
||||
end)
|
||||
|
||||
it('returns empty for tasks without forge refs', function()
|
||||
local lines = {
|
||||
'# Inbox',
|
||||
'- [ ] Plain task',
|
||||
}
|
||||
local refs = diff.apply(lines, s)
|
||||
assert.are.equal(0, #refs)
|
||||
end)
|
||||
|
||||
it('returns forge refs for duplicated tasks', function()
|
||||
s:add({
|
||||
description = 'Fix bug gh:user/repo#42',
|
||||
_extra = {
|
||||
_forge_ref = {
|
||||
forge = 'github',
|
||||
owner = 'user',
|
||||
repo = 'repo',
|
||||
type = 'issue',
|
||||
number = 42,
|
||||
url = '',
|
||||
},
|
||||
},
|
||||
})
|
||||
s:save()
|
||||
local lines = {
|
||||
'# Todo',
|
||||
'/1/- [ ] Fix bug gh:user/repo#42',
|
||||
'/1/- [ ] Fix bug gh:user/repo#42',
|
||||
}
|
||||
local refs = diff.apply(lines, s)
|
||||
assert.are.equal(1, #refs)
|
||||
assert.are.equal(42, refs[1].number)
|
||||
end)
|
||||
|
||||
it('clears priority when [N] is removed from buffer line', function()
|
||||
s:add({ description = 'Task name', priority = 1 })
|
||||
s:save()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue