#!/usr/bin/env bats load 'test_helper' # Text Decoration @test 'Options - list blocks - 1 plain' { BATS_OUTPUT_FILTER=A \ spec_mde_args_expect \ docs/dev/text-decoration.md \ --list-blocks-message oname \ --list-blocks-type 3 \ --list-blocks \ '-:= =:- * Exit - **_Bold-Underline_** - **Bold** - **~Bold-Italic~** - __Underline__ - _~Underline-Italic~_ - `Italic` - ~~Strikethrough~~ -:= ~~~ =:-' } @test 'Options - list blocks - 2 extracts markup' { BATS_OUTPUT_FILTER=A \ spec_mde_args_expect \ docs/dev/text-decoration.md \ --list-blocks-message dname \ --list-blocks-type 3 \ --list-blocks \ '-:= =:- * Exit - Bold-Underline - Bold - Bold-Italic - Underline - Underline-Italic - Italic - Strikethrough -:= ~~~ =:-' } @test 'Options - list blocks - 3 decorates' { spec_mde_args_expect docs/dev/text-decoration.md --list-blocks-message dname --list-blocks-type 3 --list-blocks \ $'\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x32\x38\x3b\x32\x30\x38\x3b\x31\x39\x32\x6d\x2d\x3a\x3d\x20\x20\x20\x20\x20\x20\x3d\x3a\x2d\x1b\x5b\x30\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x36\x34\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2a\x20\x45\x78\x69\x74\x1b\x5b\x30\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x31\x6d\x1b\x5b\x34\x6d\x42\x6f\x6c\x64\x2d\x55\x6e\x64\x65\x72\x6c\x69\x6e\x65\x1b\x5b\x32\x32\x6d\x1b\x5b\x32\x34\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x31\x6d\x42\x6f\x6c\x64\x1b\x5b\x32\x32\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x31\x6d\x1b\x5b\x33\x6d\x42\x6f\x6c\x64\x2d\x49\x74\x61\x6c\x69\x63\x1b\x5b\x32\x32\x6d\x1b\x5b\x32\x33\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x34\x6d\x55\x6e\x64\x65\x72\x6c\x69\x6e\x65\x1b\x5b\x32\x34\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x34\x6d\x1b\x5b\x33\x6d\x55\x6e\x64\x65\x72\x6c\x69\x6e\x65\x2d\x49\x74\x61\x6c\x69\x63\x1b\x5b\x32\x33\x6d\x1b\x5b\x32\x34\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x33\x6d\x49\x74\x61\x6c\x69\x63\x1b\x5b\x32\x33\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x3b\x31\x39\x32\x6d\x2d\x20\x1b\x5b\x30\x6d\x1b\x5b\x39\x6d\x53\x74\x72\x69\x6b\x65\x74\x68\x72\x6f\x75\x67\x68\x1b\x5b\x32\x39\x6d\x0a\x1b\x5b\x33\x38\x3b\x32\x3b\x31\x32\x38\x3b\x32\x30\x38\x3b\x31\x39\x32\x6d\x2d\x3a\x3d\x20\x20\x20\x7e\x7e\x7e\x20\x20\x20\x3d\x3a\x2d\x1b\x5b\x30\x6d' } # Raw comparison test #@test "raw comparison" { # expect_equal_raw "Hello, World!" "Hello, World!" #} # remove_ansi_escape_sequences2() { # # printf '%s' "$1" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g' | tr '\n\t\r\v\f' ' ' # # printf '%s' "$1" | sed -E 's/\x1b\[[0-9;]*[a-zA-Z]//g' # # printf '%s' "$1" | sed -E 's/e/E/g' | tr '\n\t\r\v\f' ' ' # printf '%s' "$1" | perl -pe 's/\e\[[0-9;]*[a-zA-Z]//g' # } # test ANSI escape sequence removal within BATS @test "comparison with ANSI removal" { actual="Hello, \e[31mWorld\e[0m!" echo 'actual' echo -en "$actual" | hexdump -C echo 'converted' converted="$(remove_ansi_escape_sequences "$actual")" echo -en "$converted" | hexdump -C [[ "Hello, World!" == "$converted" ]] echo "converision passed" # (( 0 == 1 )) # force output } #@test 'Defaults' { # run_mde_args_expect_raw \ # docs/dev/specs.md bash1 \ # '\nbash1!' #} # @test 'OK' { # run_mde_specs_md_args_expect_xansi '[VARIABLE1]' '__Exit' ' VARIABLE1: 1' # }