aboutsummaryrefslogtreecommitdiff
path: root/.vim/bundle/vim-airline/t/builder.vim
blob: 3d1afcda3929932c537ccf0dbc2a4cad6dc576a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
let g:airline_theme = 'dark'
call airline#init#bootstrap()

describe 'active builder'
  before
    let s:builder = airline#builder#new({'active': 1})
  end

  it 'should start with an empty statusline'
    let stl = s:builder.build()
    Expect stl == ''
  end

  it 'should transition colors from one to the next'
    call s:builder.add_section('Normal', 'hello')
    call s:builder.add_section('NonText', 'world')
    let stl = s:builder.build()
    Expect stl =~ '%#Normal#hello%#Normal_to_NonText#>%#NonText#world'
  end

  it 'should split left/right sections'
    call s:builder.split()
    let stl = s:builder.build()
    Expect stl =~ '%='
  end

  it 'after split, sections use the right separator'
    call s:builder.split()
    call s:builder.add_section('Normal', 'hello')
    call s:builder.add_section('NonText', 'world')
    let stl = s:builder.build()
    Expect stl =~ '%#Normal#hello%#Normal_to_NonText#<%#NonText#world'
  end

  it 'should not repeat the same highlight group'
    call s:builder.add_section('Normal', 'hello')
    call s:builder.add_section('Normal', 'hello')
    let stl = s:builder.build()
    Expect stl == '%#Normal#hello>hello'
  end

  it 'should replace accent groups with the specified group'
    call s:builder.add_section('Normal', '%#__accent_foo#hello')
    let stl = s:builder.build()
    Expect stl == '%#Normal#%#Normal_foo#hello'
  end

  it 'should replace two accent groups with correct groups'
    call s:builder.add_section('Normal', '%#__accent_foo#hello%#__accent_bar#world')
    let stl = s:builder.build()
    Expect stl =~ '%#Normal_foo#hello%#Normal_bar#world'
  end

  it 'should special restore group should go back to previous group'
    call s:builder.add_section('Normal', '%#__restore__#')
    let stl = s:builder.build()
    Expect stl !~ '%#__restore__#'
    Expect stl =~ '%#Normal#'
  end
end

describe 'inactive builder'
  before
    let s:builder = airline#builder#new({'active': 0})
  end

  it 'should transition colors from one to the next'
    call s:builder.add_section('Normal', 'hello')
    call s:builder.add_section('NonText', 'world')
    let stl = s:builder.build()
    Expect stl =~ '%#Normal_inactive#hello%#Normal_to_NonText_inactive#>%#NonText_inactive#world'
  end

  it 'should not render accents'
    call s:builder.add_section('Normal', '%#__accent_foo#hello%#foo#foo%#__accent_bar#world')
    let stl = s:builder.build()
    Expect stl == '%#Normal_inactive#hello%#foo_inactive#fooworld'
  end
end