aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.local/share/nvim/site/t/section.vim
diff options
context:
space:
mode:
authorYaroslav <contact@yaroslavps.com>2020-03-31 17:52:49 +0300
committerYaroslav <contact@yaroslavps.com>2020-03-31 17:52:49 +0300
commit7217c7749e5403c9c7856c1d12c7986eb9c3b460 (patch)
treed60a112d9119a51af1cf5f590c5efad81751edf6 /dotfiles/.local/share/nvim/site/t/section.vim
parent9a3aa7b20a67c1b7991da1da9508ad5f78f76352 (diff)
downloadvimrice-7217c7749e5403c9c7856c1d12c7986eb9c3b460.tar.gz
vimrice-7217c7749e5403c9c7856c1d12c7986eb9c3b460.zip
Goodbye vim, been using neovim for ages now; home directory cleanup
Diffstat (limited to 'dotfiles/.local/share/nvim/site/t/section.vim')
-rw-r--r--dotfiles/.local/share/nvim/site/t/section.vim80
1 files changed, 80 insertions, 0 deletions
diff --git a/dotfiles/.local/share/nvim/site/t/section.vim b/dotfiles/.local/share/nvim/site/t/section.vim
new file mode 100644
index 0000000..50717a7
--- /dev/null
+++ b/dotfiles/.local/share/nvim/site/t/section.vim
@@ -0,0 +1,80 @@
+function! SectionSpec()
+endfunction
+
+describe 'section'
+ before
+ call airline#parts#define_text('text', 'text')
+ call airline#parts#define_raw('raw', 'raw')
+ call airline#parts#define_function('func', 'SectionSpec')
+ end
+
+ it 'should be able to reference default parts'
+ let s = airline#section#create(['paste'])
+ Expect s == '%{airline#util#wrap(airline#parts#paste(),0)}'
+ end
+
+ it 'should create sections with no separators'
+ let s = airline#section#create(['text', 'raw', 'func'])
+ Expect s == '%{airline#util#wrap("text",0)}raw%{airline#util#wrap(SectionSpec(),0)}'
+ end
+
+ it 'should create left sections with separators'
+ let s = airline#section#create_left(['text', 'text'])
+ Expect s == '%{airline#util#wrap("text",0)}%{airline#util#append("text",0)}'
+ end
+
+ it 'should create right sections with separators'
+ let s = airline#section#create_right(['text', 'text'])
+ Expect s == '%{airline#util#prepend("text",0)}%{airline#util#wrap("text",0)}'
+ end
+
+ it 'should prefix with accent group if provided and restore afterwards'
+ call airline#parts#define('hi', {
+ \ 'raw': 'hello',
+ \ 'accent': 'red',
+ \ })
+ let s = airline#section#create(['hi'])
+ Expect s == '%#__accent_red#hello%#__restore__#'
+ end
+
+ it 'should accent functions'
+ call airline#parts#define_function('hi', 'Hello')
+ call airline#parts#define_accent('hi', 'bold')
+ let s = airline#section#create(['hi'])
+ Expect s == '%#__accent_bold#%{airline#util#wrap(Hello(),0)}%#__restore__#'
+ end
+
+ it 'should parse out a section from the distro'
+ call airline#extensions#load()
+ let s = airline#section#create(['whitespace'])
+ Expect s =~ 'airline#extensions#whitespace#check'
+ end
+
+ it 'should use parts as is if they are not found'
+ let s = airline#section#create(['asdf', 'func'])
+ Expect s == 'asdf%{airline#util#wrap(SectionSpec(),0)}'
+ end
+
+ it 'should force add separators for raw and missing keys'
+ let s = airline#section#create_left(['asdf', 'raw'])
+ Expect s == 'asdf raw'
+ let s = airline#section#create_left(['asdf', 'aaaa', 'raw'])
+ Expect s == 'asdf aaaa raw'
+ let s = airline#section#create_right(['raw', '%f'])
+ Expect s == 'raw %f'
+ let s = airline#section#create_right(['%t', 'asdf', '%{getcwd()}'])
+ Expect s == '%t asdf %{getcwd()}'
+ end
+
+ it 'should empty out parts that do not pass their condition'
+ call airline#parts#define_text('conditional', 'conditional')
+ call airline#parts#define_condition('conditional', '0')
+ let s = airline#section#create(['conditional'])
+ Expect s == '%{0 ? airline#util#wrap("conditional",0) : ""}'
+ end
+
+ it 'should not draw two separators after another'
+ let s = airline#section#create_right(['ffenc','%{strftime("%H:%M")}'])
+ Expect s == '%{airline#util#prepend(airline#parts#ffenc(),0)}%{strftime("%H:%M")}'
+ end
+end