#!/usr/bin/env roundup

describe libremessages

. ./test-common.sh

before() {
	_before
}

after() {
	_after
}

it_can_be_included_twice() (
	. libremessages
	. libremessages
)

it_can_be_included_with_set_euE() (
	set -euE
	. libremessages
)

it_works_with_no_color_and_set_euE() (
	(
		unset TERM
		set -euE
		. libremessages
		msg Foo
	) >$tmpdir/stdout 2>$tmpdir/stderr

	empty $tmpdir/stdout
	! empty $tmpdir/stderr
)

it_can_be_called_without_including() {
	libremessages msg Foo >$tmpdir/stdout 2>$tmpdir/stderr

	empty $tmpdir/stdout
	! empty $tmpdir/stderr
}

it_fails_with_msg_and_no_args() {
	ret=0
	libremessages msg || ret=$?
	[[ $ret != 0 ]]
}