drop_spec.lua (3252B)
1 local n = require('test.functional.testnvim')() 2 local Screen = require('test.functional.ui.screen') 3 4 local command = n.command 5 local clear, feed, feed_command = n.clear, n.feed, n.feed_command 6 local exec = n.exec 7 8 describe(':drop', function() 9 local screen 10 11 before_each(function() 12 clear() 13 screen = Screen.new(35, 10) 14 screen:set_default_attr_ids({ 15 [0] = { bold = true, foreground = Screen.colors.Blue }, 16 [1] = { bold = true, reverse = true }, 17 [2] = { reverse = true }, 18 [3] = { bold = true }, 19 }) 20 command('set nohidden laststatus=2 shortmess-=F') 21 end) 22 23 it('works like :e when called with only one window open', function() 24 feed_command('drop tmp1.vim') 25 screen:expect([[ 26 ^ | 27 {0:~ }|*7 28 {1:tmp1.vim }| 29 "tmp1.vim" [New] | 30 ]]) 31 end) 32 33 it('switches to an open window showing the buffer', function() 34 feed_command('edit tmp1') 35 feed_command('vsplit') 36 feed_command('edit tmp2') 37 feed_command('drop tmp1') 38 screen:expect([[ 39 │^ | 40 {0:~ }│{0:~ }|*7 41 {2:tmp2 }{1:tmp1 }| 42 "tmp1" [New] | 43 ]]) 44 end) 45 46 it("splits off a new window when a buffer can't be abandoned", function() 47 feed_command('edit tmp1') 48 feed_command('vsplit') 49 feed_command('edit tmp2') 50 feed('iABC<esc>') 51 feed_command('drop tmp3') 52 screen:expect([[ 53 ^ │ | 54 {0:~ }│{0:~ }|*3 55 {1:tmp3 }│{0:~ }| 56 ABC │{0:~ }| 57 {0:~ }│{0:~ }|*2 58 {2:tmp2 [+] tmp1 }| 59 "tmp3" [New] | 60 ]]) 61 end) 62 63 -- oldtest: Test_drop_modified_file() 64 it('does not cause E37 with modified same file', function() 65 exec([[ 66 edit Xdrop_modified.txt 67 call setline(1, 'The quick brown fox jumped over the lazy dogs') 68 ]]) 69 feed_command('drop Xdrop_modified.txt') 70 screen:expect([[ 71 ^The quick brown fox jumped over the| 72 lazy dogs | 73 {0:~ }|*6 74 {1:Xdrop_modified.txt [+] }| 75 :drop Xdrop_modified.txt | 76 ]]) 77 end) 78 79 it('jumps to line number when passed +line', function() 80 exec([[ 81 edit Xdrop_line.txt 82 call append(0, "I just miss doing art. Don't you?") 83 call append(1, "It is not so hard as we have supposed.") 84 call append(2, "We are propelled by disaster. We are moving swiftly.") 85 ]]) 86 feed_command('drop +2 Xdrop_line.txt') 87 screen:expect([[ 88 I just miss doing art. Don't you? | 89 ^It is not so hard as we have suppos| 90 ed. | 91 We are propelled by disaster. We ar| 92 e moving swiftly. | 93 | 94 {0:~ }|*2 95 {1:Xdrop_line.txt [+] }| 96 :drop +2 Xdrop_line.txt | 97 ]]) 98 end) 99 end)