-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.lua
More file actions
71 lines (56 loc) · 2.25 KB
/
test.lua
File metadata and controls
71 lines (56 loc) · 2.25 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
#!/usr/bin/env lua
-- Simple test script for diffy plugin
-- This would be run with: nvim --headless -c "luafile test.lua"
local function test_git_parsing()
print("Testing git diff parsing...")
-- Mock diff output
local mock_diff = [[
diff --git a/test.txt b/test.txt
index 1234567..abcdef0 100644
--- a/test.txt
+++ b/test.txt
@@ -1,3 +1,4 @@
line 1
-line 2
+modified line 2
line 3
+new line 4
]]
local git = require("diffy.git")
local result = git.parse_and_align_diff(mock_diff)
assert(result, "Diff parsing failed")
assert(#result.left_content > 0, "Left content is empty")
assert(#result.right_content > 0, "Right content is empty")
-- Verify content alignment (GitHub-style pairing)
-- Line 1 is context
assert(result.left_content[1] == "line 1", "Expected line 1 context")
assert(result.right_content[1] == "line 1", "Expected line 1 context")
-- Line 2: deletion paired with addition (GitHub-style)
assert(result.left_content[2] == "line 2", "Expected line 2 removed on left")
assert(result.right_content[2] == "modified line 2", "Expected modified line 2 on right (paired)")
-- Line 3 is context
assert(result.left_content[3] == "line 3", "Expected line 3 context")
assert(result.right_content[3] == "line 3", "Expected line 3 context")
-- Line 4: pure addition (empty on left)
assert(result.left_content[4] == "", "Expected line 4 empty in left")
assert(result.right_content[4] == "new line 4", "Expected new line 4 added in right")
-- Verify word_diffs exists for paired modification
assert(result.word_diffs, "Expected word_diffs table")
assert(result.word_diffs[2], "Expected word diff for line 2 (paired modification)")
print("✓ Git parsing test passed")
end
local function test_ui_creation()
print("Testing UI creation...")
-- This would require a running Neovim instance to test properly
-- For now, just test that the module loads
local ui = require("diffy.ui")
assert(ui, "UI module failed to load")
assert(type(ui.open_diff_window) == "function", "open_diff_window is not a function")
assert(type(ui.close_diff_window) == "function", "close_diff_window is not a function")
print("✓ UI creation test passed")
end
-- Run tests
print("Running diffy plugin tests...")
test_git_parsing()
test_ui_creation()
print("All tests passed! ✓")