2018-06-22 16:35:24 +00:00
|
|
|
const tap = require('tap')
|
2018-07-10 17:51:32 +00:00
|
|
|
const calcWidth = require('../lib/calc-text-width.js').Verdana11
|
2018-06-22 16:35:24 +00:00
|
|
|
|
|
|
|
tap.test('calc width for "npm"', t => {
|
2018-07-11 05:36:30 +00:00
|
|
|
t.ok(typeof calcWidth === 'function', 'export calcWidth function')
|
2018-07-10 17:51:32 +00:00
|
|
|
t.ok(Number.isFinite(calcWidth('npm')), 'result is a number')
|
2018-07-11 05:36:30 +00:00
|
|
|
t.is(calcWidth('npm'), 24.9, 'result is correct value')
|
2018-06-22 16:35:24 +00:00
|
|
|
t.end()
|
|
|
|
})
|
2018-07-18 05:59:40 +00:00
|
|
|
|
|
|
|
tap.test('exception handling', t => {
|
|
|
|
t.throws(() => calcWidth(0), TypeError, 'throw if feed with non-string input')
|
|
|
|
t.end()
|
|
|
|
})
|