Skip to content
Snippets Groups Projects
Commit 65dde580 authored by Alyssa Ross's avatar Alyssa Ross
Browse files

tests: add some emoji tests :100:

parent b0fea9eb
No related branches found
No related tags found
No related merge requests found
require "testing_env"
require "emoji"
class EmojiTest < Homebrew::TestCase
def test_install_badge
assert_equal "🍺", Emoji.install_badge
ENV["HOMEBREW_INSTALL_BADGE"] = "foo"
assert_equal "foo", Emoji.install_badge
end
end
......@@ -9,6 +9,14 @@ class UtilTests < Homebrew::TestCase
@dir = Pathname.new(mktmpdir)
end
# Helper for matching escape sequences.
def e(code)
/(\e\[\d+m)*\e\[#{code}m/
end
# Helper for matching that style is reset at the end of a string.
Z = /(\e\[\d+m)*\e\[0m\Z/
def test_ofail
shutup { ofail "foo" }
assert Homebrew.failed?
......@@ -22,11 +30,25 @@ class UtilTests < Homebrew::TestCase
end
def test_pretty_installed
$stdout.stubs(:tty?).returns true
ENV.delete("HOMEBREW_NO_EMOJI")
assert_match(/\A#{e 1}foo #{e 32}#{Z}/, pretty_installed("foo"))
ENV["HOMEBREW_NO_EMOJI"] = "1"
assert_match(/\A#{e 1}foo \(installed\)#{Z}/, pretty_installed("foo"))
$stdout.stubs(:tty?).returns false
assert_equal "foo", pretty_installed("foo")
end
def test_pretty_uninstalled
$stdout.stubs(:tty?).returns true
ENV.delete("HOMEBREW_NO_EMOJI")
assert_match(/\A#{e 1}foo #{e 31}#{Z}/, pretty_uninstalled("foo"))
ENV["HOMEBREW_NO_EMOJI"] = "1"
assert_match(/\A#{e 1}foo \(uninstalled\)#{Z}/, pretty_uninstalled("foo"))
$stdout.stubs(:tty?).returns false
assert_equal "foo", pretty_uninstalled("foo")
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment