Posts

Showing posts with the label ava

Failing ava tests pass on adding console.log statement

Failing ava tests pass on adding console.log statement Here's the function being tested: const delimitedBinary = /^(?:[01]{8} ){3,}$/gm; const nonDelimitedBinary = /^(?:[01]{8}){3,}$/gm; const byteRegex = /[01]{8}/gm; function decode(string) { string = string.trim(); let bytes; if (delimitedBinary.test(string + ' ')) { bytes = (string + ' ').match(byteRegex); } else if(nonDelimitedBinary.test(string)) { bytes = string.match(byteRegex); } if (bytes) { return decodeBytes(bytes); } return ''; } function decodeBytes(bytes) { return utf.getStringFromBytes(bytes.map(byte => parseInt(byte, 2))); } I have some tests in test/tests.js . Here's an excerpt: test/tests.js test('Decodes binary on separate line', t => { t.is(app.decode('text n01110000 01100001 01110011 01110011'), 'pass'); }); test('Decodes emojis', t => { t.is(app.decode('11110000 10011111 ...