-
-
Notifications
You must be signed in to change notification settings - Fork 188
Expand file tree
/
Copy pathpriority_spec.lua
More file actions
139 lines (125 loc) · 4.14 KB
/
Copy pathpriority_spec.lua
File metadata and controls
139 lines (125 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
local config = require('orgmode.config')
local helpers = require('tests.plenary.helpers')
describe('Priority mappings', function()
local alpha_config = function()
config:extend({
org_priority_highest = 'A',
org_priority_default = 'C',
org_priority_lowest = 'E',
})
end
local numeric_config = function()
config:extend({
org_priority_highest = 1,
org_priority_default = 5,
org_priority_lowest = 15,
})
end
after_each(function()
vim.cmd([[silent! %bw!]])
end)
it('should increase the priority of the current headline', function()
helpers.create_file({
'* TODO [#B] Test orgmode',
})
vim.fn.cursor(1, 1)
assert.are.same('* TODO [#B] Test orgmode', vim.fn.getline(1))
vim.cmd('norm ciR')
assert.are.same('* TODO [#A] Test orgmode', vim.fn.getline(1))
end)
it('should decrease the priority of the current headline', function()
helpers.create_file({
'* TODO [#B] Test orgmode',
})
vim.fn.cursor(1, 1)
assert.are.same('* TODO [#B] Test orgmode', vim.fn.getline(1))
vim.cmd('norm cir')
assert.are.same('* TODO [#C] Test orgmode', vim.fn.getline(1))
end)
it('should set the priority based on the input key', function()
helpers.create_file({
'* TODO [#B] Test orgmode',
})
vim.fn.cursor(1, 1)
assert.are.same('* TODO [#B] Test orgmode', vim.fn.getline(1))
vim.cmd('norm ,o,a\r')
assert.are.same('* TODO [#A] Test orgmode', vim.fn.getline(1))
end)
it('should remove the priority if <Space> is pressed', function()
helpers.create_file({
'* TODO [#B] Test orgmode',
})
vim.fn.cursor(1, 1)
assert.are.same('* TODO [#B] Test orgmode', vim.fn.getline(1))
vim.cmd('norm ,o, \r')
assert.are.same('* TODO Test orgmode', vim.fn.getline(1))
end)
it('should do nothing if <Space> is pressed on a line without a priority', function()
alpha_config()
helpers.create_file({
'* TODO Test orgmode',
})
vim.fn.cursor(1, 1)
assert.are.same('* TODO Test orgmode', vim.fn.getline(1))
vim.cmd('norm ,o, \r')
assert.are.same('* TODO Test orgmode', vim.fn.getline(1))
end)
it('should add a priority if the item does not already have one', function()
helpers.create_file({
'* TODO Test orgmode',
})
vim.fn.cursor(1, 1)
assert.are.same('* TODO Test orgmode', vim.fn.getline(1))
vim.cmd('norm ,o,a\r')
assert.are.same('* TODO [#A] Test orgmode', vim.fn.getline(1))
end)
it('should add a priority if the item has no todo keyword', function()
helpers.create_file({
'* Test orgmode',
})
vim.fn.cursor(1, 1)
assert.are.same('* Test orgmode', vim.fn.getline(1))
vim.cmd('norm ,o,a\r')
assert.are.same('* [#A] Test orgmode', vim.fn.getline(1))
end)
it('should increase the default character priority, when it is explicitly defined', function()
alpha_config()
helpers.create_file({
'* [#C] Test orgmode',
})
vim.fn.cursor(1, 1)
assert.are.same('* [#C] Test orgmode', vim.fn.getline(1))
vim.cmd('norm ciR')
assert.are.same('* [#B] Test orgmode', vim.fn.getline(1))
end)
it('should increase a numeric priority, which is not explicitly defined', function()
numeric_config()
helpers.create_file({
'* [#5] Test orgmode',
})
vim.fn.cursor(1, 1)
assert.are.same('* [#5] Test orgmode', vim.fn.getline(1))
vim.cmd('norm ciR')
assert.are.same('* [#4] Test orgmode', vim.fn.getline(1))
end)
it('should increase a character priority, which is not explicitly defined', function()
alpha_config()
helpers.create_file({
'* [#D] Test orgmode',
})
vim.fn.cursor(1, 1)
assert.are.same('* [#D] Test orgmode', vim.fn.getline(1))
vim.cmd('norm ciR')
assert.are.same('* [#C] Test orgmode', vim.fn.getline(1))
end)
it('should increase a numeric priority, which is not explicitly defined', function()
numeric_config()
helpers.create_file({
'* [#10] Test orgmode',
})
vim.fn.cursor(1, 1)
assert.are.same('* [#10] Test orgmode', vim.fn.getline(1))
vim.cmd('norm ciR')
assert.are.same('* [#9] Test orgmode', vim.fn.getline(1))
end)
end)