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
|
|
|
|
2018-07-18 06:11:11 +00:00
|
|
|
tap.test('basic functions', t => {
|
2018-07-11 05:36:30 +00:00
|
|
|
t.ok(typeof calcWidth === 'function', 'export calcWidth function')
|
2018-07-18 06:11:11 +00:00
|
|
|
t.ok(Number.isFinite(calcWidth('')), 'result is a number')
|
|
|
|
t.ok(calcWidth('') === 0, 'return 0 for empty string')
|
|
|
|
t.end()
|
|
|
|
})
|
|
|
|
|
|
|
|
tap.test('calc width for "npm"', t => {
|
2018-07-19 06:39:31 +00:00
|
|
|
t.matchSnapshot(calcWidth('npm'), 'result is correct')
|
2018-06-22 16:35:24 +00:00
|
|
|
t.end()
|
|
|
|
})
|
2018-07-18 05:59:40 +00:00
|
|
|
|
2018-07-18 06:11:11 +00:00
|
|
|
tap.test('calc width for unicode', t => {
|
2018-07-19 06:39:31 +00:00
|
|
|
t.matchSnapshot(calcWidth('壹佰贰拾叁'), 'result is correct')
|
|
|
|
t.end()
|
|
|
|
})
|
|
|
|
|
|
|
|
tap.test('calc width for emojis', t => {
|
|
|
|
t.matchSnapshot(calcWidth('💩🤱🦄', true), 'result is correct')
|
2018-07-18 06:11:11 +00:00
|
|
|
t.end()
|
|
|
|
})
|