Skip to content

Commit

Permalink
Add test for binary data like in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
RenovatingDev committed Jan 31, 2022
1 parent 702296a commit 66a7bef
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/e2e/toString.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,31 @@ test('toString terminal', function (t) {
t.equal(code + '\n', expectedTerminal, 'should output a valid symbol (promise)')
})
})

test('toString byte-input', function (t) {
const expectedOutput = [
' ',
' ',
' █▀▀▀▀▀█ █▄█▀ █▀▀▀▀▀█ ',
' █ ███ █ ▀█ █▀ █ ███ █ ',
' █ ▀▀▀ █ ▀ █ █ ▀▀▀ █ ',
' ▀▀▀▀▀▀▀ █▄▀▄█ ▀▀▀▀▀▀▀ ',
' ▀██▄██▀▀▀█▀▀ ▀█ ▄▀▄ ',
' ▀█▀▄█▄▀▄ ██ ▀ ▄ ▀▄ ▀ ',
' ▀ ▀ ▀▀▀▀█▄ ▄▀▄▀▄▀▄▀▄▀ ',
' █▀▀▀▀▀█ █ █▄█▀█▄█ ▀ ',
' █ ███ █ ▀█▀▀ ▀██ ▀█▀ ',
' █ ▀▀▀ █ ██▀ ▀ ▄ ▀▄▀▄▀ ',
' ▀▀▀▀▀▀▀ ▀▀▀ ▀ ▀▀▀ ▀▀▀ ',
' ',
' '
].join('\n')
const byteInput = new Uint8ClampedArray([1, 2, 3, 4, 5])

t.plan(2)

QRCode.toString([{ data: byteInput, mode: 'byte' }], { errorCorrectionLevel: 'L' }, (err, code) => {
t.ok(!err, 'there should be no error')
t.equal(code, expectedOutput, 'should output the correct code')
})
})

0 comments on commit 66a7bef

Please sign in to comment.