forked from Shopify/cli-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathansi_test.rb
34 lines (26 loc) · 959 Bytes
/
ansi_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'test_helper'
module CLI
module UI
class ANSITest < Minitest::Test
extend T::Sig
def test_sgr
assert_equal("\x1b[1;34m", ANSI.sgr('1;34'))
end
def test_printing_width
assert_equal(4, ANSI.printing_width("\x1b[38;2;100;100;100mtest\x1b[0m"))
assert_equal(0, ANSI.printing_width(''))
assert_equal(3, ANSI.printing_width('>🔧<'))
assert_equal(1, ANSI.printing_width('👩💻'))
end
def test_line_skip_with_shift
next_line_expected = "\e[1B\e[1G"
previous_line_expected = "\e[1A\e[1G"
assert_equal(next_line_expected, ANSI.next_line)
assert_equal(previous_line_expected, ANSI.previous_line)
CLI::UI::OS.stubs(:current).returns(CLI::UI::OS::WINDOWS)
assert_equal("#{next_line_expected}\e[1D", ANSI.next_line)
assert_equal("#{previous_line_expected}\e[1D", ANSI.previous_line)
end
end
end
end