From 21a2198a12bc428c73767a81063330d9dc8767e1 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Tue, 19 Oct 2021 12:07:12 -0400 Subject: [PATCH] test/theme: make fewer assumptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Literally copying a line from the source to be tested is perhaps not the best way to test that code. 😉 That said, we do want to verify that the function was actually loaded. TODO: actually test the function. --- test/themes/base.theme.bats | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test/themes/base.theme.bats b/test/themes/base.theme.bats index 2e15e865..50098c1d 100644 --- a/test/themes/base.theme.bats +++ b/test/themes/base.theme.bats @@ -18,30 +18,32 @@ load ../../themes/base.theme } @test 'themes base: battery_char should exist' { - run type -a battery_char &> /dev/null + run type -t battery_char assert_success + assert_line "function" run battery_char - assert_success assert_line -n 0 "" - - run type -a battery_char - assert_line " echo -n" } @test 'themes base: battery_char should exist if battery plugin loaded' { unset -f battery_char - load ../../plugins/available/battery.plugin - load ../../themes/base.theme - run type -a battery_char &> /dev/null + load ../../plugins/available/battery.plugin + run type -t battery_percentage assert_success + assert_line "function" + + load ../../themes/base.theme + run type -t battery_char + assert_success + assert_line "function" run battery_char assert_success run type -a battery_char - assert_line ' if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" = true ]]; then' + assert_output --partial 'THEME_BATTERY_PERCENTAGE_CHECK' } @test 'themes base: battery_charge should exist' {