Description
I was experiencing an error when producing tests for a program that used this package, and it didn't seem to make sense. When I tried the same data in a test for stripColorsAndStyle
, it didn't seem to produce accurate results with test data ircColors.rainbow('rainbow')
.
console.log(ircColors.stripColors(ircColors.rainbow('rainbow')));
console.log(ircColors.stripColorsAndStyle(ircColors.rainbow('rainbow')));
produces:
rainbow
�rainbo�w
(i.e. ircColors.stripColorsAndStyle(ircColors.rainbow('rainbow')) !== 'rainbow'
.)
I copied the test data given for the rainbow
function, in the vows testing, into the stripColors
and stripColorsAndStyle
vows (but reverse), and only the first seems to pass. I don't think I'm doing something silly here – stripping the colors and style from a piece of rainbowed text should produce the original text, just as stripping only the colors would?
Modified tests for the vows:
'stripColors': [
'\x0304' + zero + 'h\x03\x0307' + zero + 'e\x03\x0308' + zero +
'l\x03\x0303' + zero + 'l\x03\x0312' + zero + 'o\x03 \x0302' + zero +
'u\x03',
'hello u'
],
'stripColorsAndStyle': [
'\x0304' + zero + 'h\x03\x0307' + zero + 'e\x03\x0308' + zero +
'l\x03\x0303' + zero + 'l\x03\x0312' + zero + 'o\x03 \x0302' + zero +
'u\x03',
'hello u'
]
Error produced:
✓ stripColors
…
✗ stripColorsAndStyle
» expected {
0: 104,
1: 101,
2: 108,
3: 108,
4: 111,
5: 32,
6: 117
},
got {
0: 2,
1: 104,
2: 101,
3: 108,
4: 108,
5: 111,
6: 32,
7: 2,
8: 117
} (deepEqual) // /home/throne3d/irc-colors.js/test/main-test.js:106
This appears in both regular and global syntax.
Another problem, possibly related, happens with nested styling. For example,
console.log(ircColors.stripStyle(ircColors.bold(`bold text, ${ircColors.italic('italic and bold text')}`)));
produces:
bold text, �italic and bold text�
Am I missing something?