-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bc308a
commit 5b6b7ca
Showing
5 changed files
with
32 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
* text=auto | ||
*.js text eol=lf | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- '10' | ||
- '8' | ||
- '6' | ||
- '4' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
import test from 'ava'; | ||
import m from '.'; | ||
import stringWidth from '.'; | ||
|
||
test('main', t => { | ||
t.is(m('abcde'), 5); | ||
t.is(m('古池や'), 6); | ||
t.is(m('あいうabc'), 9); | ||
t.is(m('ノード.js'), 9); | ||
t.is(m('你好'), 4); | ||
t.is(m('안녕하세요'), 10); | ||
t.is(m('A\uD83C\uDE00BC'), 5, 'surrogate'); | ||
t.is(m('\u001B[31m\u001B[39m'), 0); | ||
t.is(m('\u{231A}'), 2, '⌚ default emoji presentation character (Emoji_Presentation)'); | ||
t.is(m('\u{2194}\u{FE0F}'), 2, '↔️ default text presentation character rendered as emoji'); | ||
t.is(m('\u{1F469}'), 2, '👩 emoji modifier base (Emoji_Modifier_Base)'); | ||
t.is(m('\u{1F469}\u{1F3FF}'), 2, '👩🏿 emoji modifier base followed by a modifier'); | ||
t.is(stringWidth('abcde'), 5); | ||
t.is(stringWidth('古池や'), 6); | ||
t.is(stringWidth('あいうabc'), 9); | ||
t.is(stringWidth('ノード.js'), 9); | ||
t.is(stringWidth('你好'), 4); | ||
t.is(stringWidth('안녕하세요'), 10); | ||
t.is(stringWidth('A\uD83C\uDE00BC'), 5, 'surrogate'); | ||
t.is(stringWidth('\u001B[31m\u001B[39m'), 0); | ||
t.is(stringWidth('\u{231A}'), 2, '⌚ default emoji presentation character (Emoji_Presentation)'); | ||
t.is(stringWidth('\u{2194}\u{FE0F}'), 2, '↔️ default text presentation character rendered as emoji'); | ||
t.is(stringWidth('\u{1F469}'), 2, '👩 emoji modifier base (Emoji_Modifier_Base)'); | ||
t.is(stringWidth('\u{1F469}\u{1F3FF}'), 2, '👩🏿 emoji modifier base followed by a modifier'); | ||
}); | ||
|
||
test('ignores control characters', t => { | ||
t.is(m(String.fromCharCode(0)), 0); | ||
t.is(m(String.fromCharCode(31)), 0); | ||
t.is(m(String.fromCharCode(127)), 0); | ||
t.is(m(String.fromCharCode(134)), 0); | ||
t.is(m(String.fromCharCode(159)), 0); | ||
t.is(m('\u001B'), 0); | ||
t.is(stringWidth(String.fromCharCode(0)), 0); | ||
t.is(stringWidth(String.fromCharCode(31)), 0); | ||
t.is(stringWidth(String.fromCharCode(127)), 0); | ||
t.is(stringWidth(String.fromCharCode(134)), 0); | ||
t.is(stringWidth(String.fromCharCode(159)), 0); | ||
t.is(stringWidth('\u001B'), 0); | ||
}); | ||
|
||
test('handles combining characters', t => { | ||
t.is(m('x\u0300'), 1); | ||
t.is(stringWidth('x\u0300'), 1); | ||
}); |