section.vimspec 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. Describe section
  2. Before
  3. call airline#parts#define_text('text', 'text')
  4. call airline#parts#define_raw('raw', 'raw')
  5. call airline#parts#define_function('func', 'SectionSpec')
  6. End
  7. It should be able to reference default parts
  8. let s = airline#section#create(['paste'])
  9. Assert Equals(s, '%{airline#util#wrap(airline#parts#paste(),0)}')
  10. End
  11. It should create sections wIth no separators
  12. let s = airline#section#create(['text', 'raw', 'func'])
  13. Assert Equals(s, '%{airline#util#wrap("text",0)}raw%{airline#util#wrap(SectionSpec(),0)}')
  14. End
  15. It should create left sections with separators
  16. let s = airline#section#create_left(['text', 'text'])
  17. Assert Equals(s, '%{airline#util#wrap("text",0)}%{airline#util#append("text",0)}')
  18. End
  19. It should create right sections wIth separators
  20. let s = airline#section#create_right(['text', 'text'])
  21. Assert Equals(s, '%{airline#util#prepend("text",0)}%{airline#util#wrap("text",0)}')
  22. End
  23. It should prefix with accent group if provided and restore afterwards
  24. call airline#parts#define('hi', {
  25. \ 'raw': 'hello',
  26. \ 'accent': 'red',
  27. \ })
  28. let s = airline#section#create(['hi'])
  29. Assert Equals(s, '%#__accent_red#hello%#__restore__#')
  30. End
  31. It should accent functions
  32. call airline#parts#define_function('hi', 'Hello')
  33. call airline#parts#define_accent('hi', 'bold')
  34. let s = airline#section#create(['hi'])
  35. Assert Equals(s, '%#__accent_bold#%{airline#util#wrap(Hello(),0)}%#__restore__#')
  36. End
  37. It should parse out a section from the distro
  38. call airline#extensions#load()
  39. let s = airline#section#create(['whitespace'])
  40. Assert Match(s, 'airline#extensions#whitespace#check')
  41. End
  42. It should use parts as is if they are not found
  43. let s = airline#section#create(['asdf', 'func'])
  44. Assert Equals(s, 'asdf%{airline#util#wrap(SectionSpec(),0)}')
  45. End
  46. It should force add separators for raw and missing keys
  47. let s = airline#section#create_left(['asdf', 'raw'])
  48. Assert Equals(s, 'asdf raw')
  49. let s = airline#section#create_left(['asdf', 'aaaa', 'raw'])
  50. Assert Equals(s, 'asdf aaaa raw')
  51. let s = airline#section#create_right(['raw', '%f'])
  52. Assert Equals(s, 'raw %f')
  53. let s = airline#section#create_right(['%t', 'asdf', '%{getcwd()}'])
  54. Assert Equals(s, '%t asdf %{getcwd()}')
  55. End
  56. It should empty out parts that do not pass their condition
  57. call airline#parts#define_text('conditional', 'conditional')
  58. call airline#parts#define_condition('conditional', '0')
  59. let s = airline#section#create(['conditional'])
  60. Assert Equals(s, '%{0 ? airline#util#wrap("conditional",0) : ""}')
  61. End
  62. It should not draw two separators after another
  63. let s = airline#section#create_right(['ffenc','%{strftime("%H:%M")}'])
  64. Assert Equals(s, '%{airline#util#prepend(airline#parts#ffenc(),0)}%{strftime("%H:%M")}')
  65. End
  66. End