-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_ui.lua
More file actions
59 lines (44 loc) · 1.51 KB
/
test_ui.lua
File metadata and controls
59 lines (44 loc) · 1.51 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
local T = MiniTest.new_set()
T.before_each = function()
package.loaded["gitlogdiff.ui"] = nil
end
T.after_each = function() end
T["move() updates cursor"] = function()
local ui = require("gitlogdiff.ui")
ui.open({ "hash1 commit1", "hash2 commit2", "hash3 commit3" })
MiniTest.expect.equality(ui.state.cursor, 1)
ui.move(1)
MiniTest.expect.equality(ui.state.cursor, 2)
ui.move(1)
MiniTest.expect.equality(ui.state.cursor, 3)
ui.move(1)
MiniTest.expect.equality(ui.state.cursor, 3)
ui.move(-1)
MiniTest.expect.equality(ui.state.cursor, 2)
end
T["toggle() updates selection"] = function()
local ui = require("gitlogdiff.ui")
ui.open({ "hash1 commit1", "hash2 commit2" })
MiniTest.expect.equality(ui.state.selected[1], nil)
ui.toggle()
MiniTest.expect.equality(ui.state.selected[1], true)
ui.toggle()
MiniTest.expect.equality(ui.state.selected[1], false)
end
T["get_selected_hashes() works"] = function()
local ui = require("gitlogdiff.ui")
ui.open({ "abc1234 commit1", "def5678 commit2", "ghi9012 commit3" })
ui.state.selected[1] = true
ui.state.selected[3] = true
local hashes = ui.get_selected_hashes()
MiniTest.expect.equality(hashes, { "abc1234", "ghi9012" })
end
T["get_selected_indices() works"] = function()
local ui = require("gitlogdiff.ui")
ui.open({ "abc1234 commit1", "def5678 commit2", "ghi9012 commit3" })
ui.state.selected[1] = true
ui.state.selected[3] = true
local indices = ui.get_selected_indices()
MiniTest.expect.equality(indices, { 1, 3 })
end
return T