From b55c0251ed78d7e89b6bc7ae7fe9e0eaaa6b2917 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Tue, 30 May 2017 08:33:07 +0200 Subject: [PATCH] Add tests for base theme's battery functions --- test/run | 2 +- test/themes/base.theme.bats | 69 +++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 test/themes/base.theme.bats diff --git a/test/run b/test/run index 59150a39..737f17e2 100755 --- a/test/run +++ b/test/run @@ -9,4 +9,4 @@ if [ -z "${BASH_IT}" ]; then export BASH_IT=$(cd ${test_directory} && dirname $(pwd)) fi -exec $bats_executable ${CI:+--tap} ${test_directory}/{install,lib,plugins} +exec $bats_executable ${CI:+--tap} ${test_directory}/{install,lib,plugins,themes} diff --git a/test/themes/base.theme.bats b/test/themes/base.theme.bats new file mode 100644 index 00000000..6bf7efed --- /dev/null +++ b/test/themes/base.theme.bats @@ -0,0 +1,69 @@ +#!/usr/bin/env bats + +load ../test_helper +load ../../lib/composure +load ../../plugins/available/base.plugin +load ../../themes/base.theme + +@test 'themes base: battery_percentage should not exist' { + run type -a battery_percentage &> /dev/null + assert_failure +} + +@test 'themes base: battery_percentage should exist if battery plugin loaded' { + load ../../plugins/available/battery.plugin + + run type -a battery_percentage &> /dev/null + assert_success +} + +@test 'themes base: battery_char should exist' { + run type -a battery_char &> /dev/null + assert_success + + run battery_char + assert_success + assert_line "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 + assert_success + + run battery_char + assert_success + + run type -a battery_char + assert_line ' if [[ "${THEME_BATTERY_PERCENTAGE_CHECK}" = true ]]; then' +} + +@test 'themes base: battery_charge should exist' { + run type -a battery_charge &> /dev/null + assert_success + + run battery_charge + assert_success + assert_line "0" "" +} + +@test 'themes base: battery_charge should exist if battery plugin loaded' { + unset -f battery_charge + load ../../plugins/available/battery.plugin + load ../../themes/base.theme + + run type -a battery_charge &> /dev/null + assert_success + + run battery_charge + assert_success + + run type -a battery_charge + assert_line ' no)' +}