<commit_before>#!/usr/bin/env zsh

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

# ------------------------------------------------------------------------------
# SHUNIT2 HOOKS
# ------------------------------------------------------------------------------

oneTimeSetUp() {
  export TERM="xterm-256color"

  SPACESHIP_PROMPT_FIRST_PREFIX_SHOW=true
  SPACESHIP_PROMPT_ADD_NEWLINE=false
  SPACESHIP_PROMPT_ORDER=(dir)

  source spaceship.zsh
}

setUp() {
  SPACESHIP_DIR_SHOW=true
  SPACESHIP_DIR_PREFIX="in "
  SPACESHIP_DIR_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"
  SPACESHIP_DIR_TRUNC=3
  SPACESHIP_DIR_TRUNC_REPO=true
  SPACESHIP_DIR_COLOR="cyan"
}

oneTimeTearDown() {
  unset SPACESHIP_PROMPT_FIRST_PREFIX_SHOW
  unset SPACESHIP_PROMPT_ADD_NEWLINE
  unset SPACESHIP_PROMPT_ORDER
}

tearDown() {
  unset SPACESHIP_DIR_SHOW
  unset SPACESHIP_DIR_PREFIX
  unset SPACESHIP_DIR_SUFFIX
  unset SPACESHIP_DIR_TRUNC
  unset SPACESHIP_DIR_TRUNC_REPO
  unset SPACESHIP_DIR_COLOR
}

# ------------------------------------------------------------------------------
# TEST CASES
# ------------------------------------------------------------------------------

test_dir_home() {
  cd ~

  local expected="%{%B%}in %{%b%}%{%B%F{$SPACESHIP_DIR_COLOR}%}%3~%{%b%f%}%{%B%} %{%b%}"
  local actual="$(spaceship_prompt)"

  assertEquals "render dir" "$expected" "$actual"
}

test_dir_color() {
  SPACESHIP_DIR_COLOR=blue

  local expected="%{%B%}in %{%b%}%{%B%F{$SPACESHIP_DIR_COLOR}%}%3~%{%b%f%}%{%B%} %{%b%}"
  local actual="$(spaceship_prompt)"

  assertEquals "render dir with custom color" "$expected" "$actual"
}

test_dir_prefix() {
  SPACESHIP_DIR_PREFIX='prefix'
  SPACESHIP_DIR_SUFFIX=''

  local expected="%{%B%}$SPACESHIP_DIR_PREFIX%{%b%}%{%B%F{cyan}%}%3~%{%b%f%}%{%B%}$SPACESHIP_DIR_SUFFIX%{%b%}"
  local actual="$(spaceship_prompt)"

  assertEquals "render dir with prefix" "$expected" "$actual"
}

test_dir_suffix() {
  SPACESHIP_DIR_PREFIX=''
  SPACESHIP_DIR_SUFFIX='suffix'

  local expected="%{%B%}$SPACESHIP_DIR_PREFIX%{%b%}%{%B%F{cyan}%}%3~%{%b%f%}%{%B%}$SPACESHIP_DIR_SUFFIX%{%b%}"
  local actual="$(spaceship_prompt)"

  assertEquals "render dir with suffix" "$expected" "$actual"
}

test_dir_trunc() {
  SPACESHIP_DIR_TRUNC=2

  local expected="%{%B%}in %{%b%}%{%B%F{cyan}%}%$SPACESHIP_DIR_TRUNC~%{%b%f%}%{%B%} %{%b%}"
  local actual="$(spaceship_prompt)"

  assertEquals "render truncated dir" "$expected" "$actual"
}
<commit_msg>Update tests for dir section with prefix<commit_after>#!/usr/bin/env zsh

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

# ------------------------------------------------------------------------------
# SHUNIT2 HOOKS
# ------------------------------------------------------------------------------

oneTimeSetUp() {
  export TERM="xterm-256color"

  SPACESHIP_PROMPT_FIRST_PREFIX_SHOW=true
  SPACESHIP_PROMPT_ADD_NEWLINE=false
  SPACESHIP_PROMPT_ORDER=(dir)

  source spaceship.zsh
}

setUp() {
  SPACESHIP_DIR_SHOW=true
  SPACESHIP_DIR_PREFIX="in "
  SPACESHIP_DIR_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"
  SPACESHIP_DIR_TRUNC=3
  SPACESHIP_DIR_TRUNC_REPO=true
  SPACESHIP_DIR_COLOR="cyan"
}

oneTimeTearDown() {
  unset SPACESHIP_PROMPT_FIRST_PREFIX_SHOW
  unset SPACESHIP_PROMPT_ADD_NEWLINE
  unset SPACESHIP_PROMPT_ORDER
}

tearDown() {
  unset SPACESHIP_DIR_SHOW
  unset SPACESHIP_DIR_PREFIX
  unset SPACESHIP_DIR_SUFFIX
  unset SPACESHIP_DIR_TRUNC
  unset SPACESHIP_DIR_TRUNC_REPO
  unset SPACESHIP_DIR_COLOR
}

# ------------------------------------------------------------------------------
# TEST CASES
# ------------------------------------------------------------------------------

test_dir_home() {
  cd ~

  local expected="%{%B%}in %{%b%}%{%B%F{$SPACESHIP_DIR_COLOR}%}%(4~||)%3~%{%b%f%}%{%B%} %{%b%}"
  local actual="$(spaceship_prompt)"

  assertEquals "render dir" "$expected" "$actual"
}

test_dir_color() {
  SPACESHIP_DIR_COLOR=blue

  local expected="%{%B%}in %{%b%}%{%B%F{$SPACESHIP_DIR_COLOR}%}%(4~||)%3~%{%b%f%}%{%B%} %{%b%}"
  local actual="$(spaceship_prompt)"

  assertEquals "render dir with custom color" "$expected" "$actual"
}

test_dir_prefix() {
  SPACESHIP_DIR_PREFIX='prefix'
  SPACESHIP_DIR_SUFFIX=''

  local expected="%{%B%}$SPACESHIP_DIR_PREFIX%{%b%}%{%B%F{cyan}%}%(4~||)%3~%{%b%f%}%{%B%}$SPACESHIP_DIR_SUFFIX%{%b%}"
  local actual="$(spaceship_prompt)"

  assertEquals "render dir with prefix" "$expected" "$actual"
}

test_dir_suffix() {
  SPACESHIP_DIR_PREFIX=''
  SPACESHIP_DIR_SUFFIX='suffix'

  local expected="%{%B%}$SPACESHIP_DIR_PREFIX%{%b%}%{%B%F{cyan}%}%(4~||)%3~%{%b%f%}%{%B%}$SPACESHIP_DIR_SUFFIX%{%b%}"
  local actual="$(spaceship_prompt)"

  assertEquals "render dir with suffix" "$expected" "$actual"
}

test_dir_trunc() {
  SPACESHIP_DIR_TRUNC=2

  local expected="%{%B%}in %{%b%}%{%B%F{cyan}%}%($((SPACESHIP_DIR_TRUNC+1))~||)%$SPACESHIP_DIR_TRUNC~%{%b%f%}%{%B%} %{%b%}"
  local actual="$(spaceship_prompt)"

  assertEquals "render truncated dir" "$expected" "$actual"
}

{'fraction_non_alphanumeric': 0.2753824756606398, 'fraction_numerical': 0.005761970991456387, 'mean_word_length': 3.3359173126614987, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1503870', 'n_tokens_mistral': 2161, 'n_tokens_neox': 1908, 'n_words': 248}