summaryrefslogtreecommitdiff
path: root/test/core/visual_identifier.spec
blob: 8c8e31778b817f2ac3e8134ca8636c39a6ea856e (plain) (blame)
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
#!/usr/bin/env zsh
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8

# Required for shunit2 to run correctly
setopt shwordsplit
SHUNIT_PARENT=$0

function setUp() {
  export TERM="xterm-256color"
  # Load Powerlevel9k
  source powerlevel9k.zsh-theme
  source functions/*
}

function testOverwritingIconsWork() {
  local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
  POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
  local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
  local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'

  assertEquals "%K{015} %F{000%}icon-here %f%F{000}world1 %k%F{015}%f " "$(build_left_prompt)"
}

function testVisualIdentifierAppearsBeforeSegmentContentOnLeftSegments() {
  local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
  POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
  local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
  local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'

  assertEquals "%K{015} %F{000%}icon-here %f%F{000}world1 %k%F{015}%f " "$(build_left_prompt)"
}

function testVisualIdentifierAppearsAfterSegmentContentOnRightSegments() {
  local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
  POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(custom_world1)
  local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'
  local POWERLEVEL9K_CUSTOM_WORLD1_ICON='icon-here'

  assertEquals "%F{015}%f%K{015}%F{000} world1%F{000%} icon-here%f%E" "$(build_right_prompt)"
}

function testVisualIdentifierPrintsNothingIfNotAvailable() {
  local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
  POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1)
  local POWERLEVEL9K_CUSTOM_WORLD1='echo world1'

  assertEquals "%K{015} %F{000}world1 %k%F{015}%f " "$(build_left_prompt)"
}

source shunit2/shunit2