summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/ui/title_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/ui/title_spec.lua')
-rw-r--r--test/functional/ui/title_spec.lua44
1 files changed, 32 insertions, 12 deletions
diff --git a/test/functional/ui/title_spec.lua b/test/functional/ui/title_spec.lua
index 5e7c9c74b9..1004c1e77b 100644
--- a/test/functional/ui/title_spec.lua
+++ b/test/functional/ui/title_spec.lua
@@ -20,31 +20,51 @@ describe('title', function()
screen = Screen.new()
end)
- it('has correct default title with unnamed file', function()
- local expected = '[No Name] - Nvim'
+ it('defaults to "No Name" and the PWD in the title if the buffer is unnamed', function()
+ local expected = (is_os('win') and '[No Name] (C:\\) - Nvim' or '[No Name] (/) - Nvim')
+ command(is_os('win') and 'cd C:\\' or 'cd /')
command('set title')
screen:expect(function()
eq(expected, screen.title)
end)
end)
- it('has correct default title with named file', function()
- local expected = (is_os('win') and 'myfile (C:\\mydir) - Nvim' or 'myfile (/mydir) - Nvim')
- command('set title')
- command(is_os('win') and 'file C:\\mydir\\myfile' or 'file /mydir/myfile')
- screen:expect(function()
- eq(expected, screen.title)
- end)
- end)
+ it(
+ 'defaults to the filename and its directory in the title if the buffer is named as a path outside the PWD',
+ function()
+ local expected = (is_os('win') and 'myfile (C:\\mydir) - Nvim' or 'myfile (/mydir) - Nvim')
+ command('set title')
+ command(is_os('win') and 'file C:\\mydir\\myfile' or 'file /mydir/myfile')
+ screen:expect(function()
+ eq(expected, screen.title)
+ end)
+ end
+ )
+
+ it(
+ 'defaults to the filename and the PWD in the title if the buffer is a file in the PWD',
+ function()
+ local expected = (is_os('win') and 'myfile (C:\\) - Nvim' or 'myfile (/) - Nvim')
+ command('set title')
+ command(is_os('win') and 'cd C:\\' or 'cd /')
+ command('file myfile')
+ screen:expect(function()
+ eq(expected, screen.title)
+ end)
+ end
+ )
it('is updated in Insert mode', function()
+ command(is_os('win') and 'cd C:\\' or 'cd /')
api.nvim_set_option_value('title', true, {})
screen:expect(function()
- eq('[No Name] - Nvim', screen.title)
+ local expected = (is_os('win') and '[No Name] (C:\\) - Nvim' or '[No Name] (/) - Nvim')
+ eq(expected, screen.title)
end)
feed('ifoo')
screen:expect(function()
- eq('[No Name] + - Nvim', screen.title)
+ local expected = (is_os('win') and '[No Name] + (C:\\) - Nvim' or '[No Name] + (/) - Nvim')
+ eq(expected, screen.title)
end)
feed('<Esc>')
api.nvim_set_option_value('titlestring', '%m %f (%{mode(1)}) | nvim', {})