Skip to content

Commit 67699de

Browse files
slammayjammaysindresorhus
authored andcommitted
Add failing test for slicing strings styled with background and foreground color (#21)
1 parent bfb33a3 commit 67699de

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ test.failing('can slice a normal character after a colored character', t => {
5858
t.is(sliceAnsi('\u001B[31ma\u001B[39mb', 1, 2), 'b');
5959
});
6060

61+
// See https://github.com/chalk/slice-ansi/issues/22
62+
test.failing('can slice a string styled with both background and foreground', t => {
63+
// Test string: `chalk.bgGreen.black('test');`
64+
t.is(sliceAnsi('\u001B[42m\u001B[30mtest\u001B[39m\u001B[49m', 0, 1), '\u001B[42m\u001B[30mt\u001B[39m\u001B[49m');
65+
});
66+
6167
test('weird null issue', t => {
6268
const s = '\u001B[1mautotune.flipCoin("easy as") ? 🎂 : 🍰 \u001B[33m★\u001B[39m\u001B[22m';
6369
const result = sliceAnsi(s, 38);

0 commit comments

Comments
 (0)