|
|
@ -1,24 +1,30 @@ |
|
|
|
require_relative '../../lib/formatters/wrapper' |
|
|
|
require_relative '../../lib/formatters/ansi_wrapper' |
|
|
|
|
|
|
|
require 'minitest/autorun' |
|
|
|
|
|
|
|
class Wrapper2Test < Minitest::Test |
|
|
|
def test_wrap_score |
|
|
|
assert_wrap("\ |
|
|
|
********************\n\ |
|
|
|
********************\n\ |
|
|
|
**********", |
|
|
|
********************\e[0m\n\ |
|
|
|
********************\e[0m\n\ |
|
|
|
**********\e[0m", |
|
|
|
('*' * 50), 20) |
|
|
|
|
|
|
|
assert_wrap("\ |
|
|
|
> ******************\n\ |
|
|
|
> ******************\n\ |
|
|
|
> **************", |
|
|
|
> ******************\e[0m\n\ |
|
|
|
> ******************\e[0m\n\ |
|
|
|
> **************\e[0m", |
|
|
|
('*' * 50), 20, '> ') |
|
|
|
end |
|
|
|
|
|
|
|
def test_wrap_sql |
|
|
|
assert_wrap("\ |
|
|
|
\e[0m\e[0;36mELECT \"scores\".* FRO\e[0m |
|
|
|
+\e[0m\e[0;36mM \"scores\" WHERE \"sc\e[0m |
|
|
|
+\e[0m\e[0;36mores\".\"id\" = $1 LIMI\e[0m |
|
|
|
+\e[0m\e[0;36mT $2\e[0m [[\"id\", 2], [\"L |
|
|
|
IMIT\", 1]] |
|
|
|
|
|
|
|
\e[0;35mScore Load (0.6ms)\e[0m \e[0;36mS\e[0m\n\ |
|
|
|
\e[0;36mELECT \"scores\".* FRO\e[0m\n\ |
|
|
|
\e[0;36mM \"scores\" WHERE \"sc\e[0m\n\ |
|
|
@ -43,11 +49,11 @@ IMIT\", 1]]", "\ |
|
|
|
|
|
|
|
def assert_wrap(expectation, text, length, prefix = '') |
|
|
|
show_with_style(text, length, prefix) |
|
|
|
assert_equal(expectation, prefix + Wrapper.wrap(text, prefix, length - prefix.length)) |
|
|
|
assert_equal(expectation, prefix + AnsiWrapper.wrap(text, length - prefix.length, prefix)) |
|
|
|
end |
|
|
|
|
|
|
|
def show_with_style(text, length, prefix = '') |
|
|
|
expectation = Wrapper.wrap(text, prefix, length - prefix.length) |
|
|
|
expectation = AnsiWrapper.wrap(text, length - prefix.length, prefix) |
|
|
|
puts "original_o is:\n#{prefix}[#{text}]\e[0m" |
|
|
|
puts "original_i is:\n#{prefix}[#{text.inspect}]\e[0m" |
|
|
|
puts |
|
|
|