37 lines
971 B
JavaScript
37 lines
971 B
JavaScript
const test = require('tap').test
|
|
const QRCode = require('core/qrcode')
|
|
const TerminalRenderer = require('renderer/terminal')
|
|
|
|
test('TerminalRenderer interface', function (t) {
|
|
t.type(TerminalRenderer.render, 'function',
|
|
'Should have render function')
|
|
|
|
t.end()
|
|
})
|
|
|
|
test('TerminalRenderer render', function (t) {
|
|
const sampleQrData = QRCode.create('sample text', { version: 2 })
|
|
let str
|
|
|
|
t.notThrow(function () { str = TerminalRenderer.render(sampleQrData) },
|
|
'Should not throw with only qrData param')
|
|
|
|
t.notThrow(function () {
|
|
str = TerminalRenderer.render(sampleQrData, {
|
|
margin: 10,
|
|
scale: 1
|
|
})
|
|
}, 'Should not throw with options param')
|
|
|
|
t.type(str, 'string',
|
|
'Should return a string')
|
|
|
|
t.notThrow(function () {
|
|
str = TerminalRenderer.render(sampleQrData, { inverse: true })
|
|
}, 'Should not throw with inverse options')
|
|
|
|
t.type(str, 'string',
|
|
'Should return a string if inverse option is set')
|
|
|
|
t.end()
|
|
})
|