#!/usr/bin/env zunit

@teardown {
    unset YSU_HARDCORE_ALIASES
    unset YSU_HARDCORE
}

@test 'hardcore aliases - triggers hardcore message when alias is in list' {
    export YSU_HARDCORE_ALIASES=("gs" "ll")
    alias gs="git status"
    alias ll="ls -l"
    
    run _check_ysu_hardcore "gs"
    
    assert $state equals $HARDCORE_EXIT_CODE
    assert "$output" contains "You Should Use hardcore mode enabled"
}

@test 'hardcore aliases - does not kill when alias not in hardcore list' {
    export YSU_HARDCORE_ALIASES=("gs" "ll") 
    alias gs="git status"
    alias gco="git checkout"
    
    run _check_ysu_hardcore "gco"
    
    assert $state equals 0
    assert "$output" is_empty
}

@test 'hardcore aliases - does not activate when YSU_HARDCORE is set' {
    export YSU_HARDCORE=1
    export YSU_HARDCORE_ALIASES=("gs")
    alias gs="git status"
    
    # YSU_HARDCORE takes precedence, should still kill but with general message
    run _check_ysu_hardcore "gs"
    
    assert $state equals $HARDCORE_EXIT_CODE  # SIGINT exit code
}

@test 'hardcore aliases - integration with check_aliases in BESTMATCH mode' {
    export YSU_HARDCORE_ALIASES=("gs")
    alias gs="git status"
    alias g="git"
    
    # This should find gs alias and trigger hardcore mode
    run _check_aliases "git status"
    
    assert $state equals $HARDCORE_EXIT_CODE  # SIGINT exit code
}

@test 'hardcore aliases - integration with check_aliases in ALL mode' {
    export YSU_MODE="ALL"
    export YSU_HARDCORE_ALIASES=("gs")
    alias gs="git status"
    alias g="git"
    
    # This should find both aliases but only kill for gs
    run _check_aliases "git status"
    
    assert $state equals $HARDCORE_EXIT_CODE  # SIGINT exit code
}

@test 'hardcore aliases - does not trigger when hardcore alias not found' {
    export YSU_HARDCORE_ALIASES=("gco")
    alias gs="git status"
    alias g="git"
    
    # Should show normal reminder without killing
    run _check_aliases "git status"
    
    assert $state equals 0
    assert "$output" contains 'Found existing alias for "git status". You should use: "gs"'
}

@test 'hardcore aliases - empty array does not trigger' {
    export YSU_HARDCORE_ALIASES=()
    alias gs="git status"
    
    run _check_ysu_hardcore "gs"
    
    assert $state equals 0
    assert "$output" is_empty
}
