|
1 | 1 | ---@diagnostic disable: undefined-field |
2 | 2 |
|
3 | 3 | local neocrush = require 'neocrush' |
| 4 | +local terminal = require 'neocrush.terminal' |
4 | 5 |
|
5 | 6 | describe('neocrush.commands', function() |
6 | 7 | before_each(function() |
@@ -38,6 +39,16 @@ describe('neocrush.commands', function() |
38 | 39 | assert.is_not_nil(cmds.CrushFocusToggle) |
39 | 40 | end) |
40 | 41 |
|
| 42 | + it('should register CrushFocusOn command', function() |
| 43 | + local cmds = vim.api.nvim_get_commands {} |
| 44 | + assert.is_not_nil(cmds.CrushFocusOn) |
| 45 | + end) |
| 46 | + |
| 47 | + it('should register CrushFocusOff command', function() |
| 48 | + local cmds = vim.api.nvim_get_commands {} |
| 49 | + assert.is_not_nil(cmds.CrushFocusOff) |
| 50 | + end) |
| 51 | + |
41 | 52 | it('should register CrushLogs command', function() |
42 | 53 | local cmds = vim.api.nvim_get_commands {} |
43 | 54 | assert.is_not_nil(cmds.CrushLogs) |
@@ -68,4 +79,29 @@ describe('neocrush.commands', function() |
68 | 79 | assert.is_not_nil(cmds.CrushCvmLocal) |
69 | 80 | end) |
70 | 81 | end) |
| 82 | + |
| 83 | + describe('CrushWidth validation', function() |
| 84 | + it('should reject widths smaller than 1', function() |
| 85 | + local original_notify = vim.notify |
| 86 | + local original_set_width = terminal.set_width |
| 87 | + local messages = {} |
| 88 | + local called = false |
| 89 | + |
| 90 | + vim.notify = function(msg) |
| 91 | + table.insert(messages, msg) |
| 92 | + end |
| 93 | + terminal.set_width = function(width) |
| 94 | + called = true |
| 95 | + return original_set_width(width) |
| 96 | + end |
| 97 | + |
| 98 | + vim.cmd 'CrushWidth 0' |
| 99 | + |
| 100 | + assert.is_false(called) |
| 101 | + assert.truthy(messages[1]:find 'number >= 1') |
| 102 | + |
| 103 | + terminal.set_width = original_set_width |
| 104 | + vim.notify = original_notify |
| 105 | + end) |
| 106 | + end) |
71 | 107 | end) |
0 commit comments