-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtest.js
21 lines (20 loc) · 908 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import test from 'ava';
import stringLength from './index.js';
test('get the real length of a string', t => {
t.is(stringLength(''), 0);
t.is(stringLength('\u001B[1m\u001B[22m'), 0);
t.is(stringLength('\u001B[1m\u001B[22m', {countAnsiEscapeCodes: true}), 9);
t.is(stringLength('𠀔'), 1);
t.is(stringLength('foo𠁐bar𠀃'), 8);
t.is(stringLength('あ'), 1);
t.is(stringLength('谢'), 1);
t.is(stringLength('🐴'), 1);
t.is(stringLength('𝌆'), 1);
t.is(stringLength('\u001B[1mfoo\u001B[22m'), 3);
t.is(stringLength('\u001B[1mfoo\u001B[22m', {countAnsiEscapeCodes: true}), 12);
t.is(stringLength('❤️'), 1);
t.is(stringLength('👊🏽'), 1);
t.is(stringLength('🏴❤️谢👪'), 4);
t.is(stringLength('\u001B[1m👩👧👦°✿\u001B[22m'), 3);
t.is(stringLength('\u001B[1m👩👧👦°✿\u001B[22m', {countAnsiEscapeCodes: true}), 12);
});