-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
38 additions
and
35 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,4 @@ | ||
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,22 +1,22 @@ | ||
import test from 'ava'; | ||
import m from '.'; | ||
import cliTruncate from '.'; | ||
|
||
test(t => { | ||
t.is(m('unicorn', 4), 'uni…'); | ||
t.is(m('unicorn', 4, {position: 'end'}), 'uni…'); | ||
t.is(m('unicorn', 1), '…'); | ||
t.is(m('unicorn', 0), ''); | ||
t.is(m('unicorn', -4), ''); | ||
t.is(m('unicorn', 20), 'unicorn'); | ||
t.is(m('unicorn', 7), 'unicorn'); | ||
t.is(m('unicorn', 6), 'unico…'); | ||
t.is(m('\u001B[31municorn\u001B[39m', 7), '\u001B[31municorn\u001B[39m'); | ||
t.is(m('\u001B[31municorn\u001B[39m', 1), '…'); | ||
t.is(m('\u001B[31municorn\u001B[39m', 4), '\u001B[31muni\u001B[39m…'); | ||
t.is(m('a\uD83C\uDE00b\uD83C\uDE00c', 5), 'a\uD83C\uDE00b\uD83C\uDE00…', 'surrogate pairs'); | ||
t.is(m('안녕하세요', 3), '안…', 'wide char'); | ||
t.is(m('unicorn', 5, {position: 'start'}), '…corn'); | ||
t.is(m('unicorn', 6, {position: 'start'}), '…icorn'); | ||
t.is(m('unicorn', 5, {position: 'middle'}), 'un…rn'); | ||
t.is(m('unicorns', 6, {position: 'middle'}), 'uni…ns'); | ||
test('main', t => { | ||
t.is(cliTruncate('unicorn', 4), 'uni…'); | ||
t.is(cliTruncate('unicorn', 4, {position: 'end'}), 'uni…'); | ||
t.is(cliTruncate('unicorn', 1), '…'); | ||
t.is(cliTruncate('unicorn', 0), ''); | ||
t.is(cliTruncate('unicorn', -4), ''); | ||
t.is(cliTruncate('unicorn', 20), 'unicorn'); | ||
t.is(cliTruncate('unicorn', 7), 'unicorn'); | ||
t.is(cliTruncate('unicorn', 6), 'unico…'); | ||
t.is(cliTruncate('\u001B[31municorn\u001B[39m', 7), '\u001B[31municorn\u001B[39m'); | ||
t.is(cliTruncate('\u001B[31municorn\u001B[39m', 1), '…'); | ||
t.is(cliTruncate('\u001B[31municorn\u001B[39m', 4), '\u001B[31muni\u001B[39m…'); | ||
t.is(cliTruncate('a\uD83C\uDE00b\uD83C\uDE00c', 5), 'a\uD83C\uDE00b\uD83C\uDE00…', 'surrogate pairs'); | ||
t.is(cliTruncate('안녕하세요', 3), '안…', 'wide char'); | ||
t.is(cliTruncate('unicorn', 5, {position: 'start'}), '…corn'); | ||
t.is(cliTruncate('unicorn', 6, {position: 'start'}), '…icorn'); | ||
t.is(cliTruncate('unicorn', 5, {position: 'middle'}), 'un…rn'); | ||
t.is(cliTruncate('unicorns', 6, {position: 'middle'}), 'uni…ns'); | ||
}); |