kopia lustrzana https://github.com/badgen/badgen
Add test coverage report
rodzic
d371712afa
commit
4dfe3501b2
|
@ -1 +1,2 @@
|
|||
node_modules
|
||||
.nyc_output
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"bench": "node bench/index.js",
|
||||
"preview": "node preview/serve.js",
|
||||
"pretest": "npm run lint",
|
||||
"test": "tap test/*.spec.js --reporter spec"
|
||||
"test": "tap test/*.spec.js --reporter spec --100"
|
||||
},
|
||||
"devDependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
|
|
|
@ -1,13 +1,23 @@
|
|||
const tap = require('tap')
|
||||
const calcWidth = require('../lib/calc-text-width.js').Verdana11
|
||||
|
||||
tap.test('calc width for "npm"', t => {
|
||||
tap.test('basic functions', t => {
|
||||
t.ok(typeof calcWidth === 'function', 'export calcWidth function')
|
||||
t.ok(Number.isFinite(calcWidth('npm')), 'result is a number')
|
||||
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 => {
|
||||
t.is(calcWidth('npm'), 24.9, 'result is correct value')
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test('calc width for unicode', t => {
|
||||
t.is(calcWidth('壹佰贰拾叁'), 55, 'result is correct value')
|
||||
t.end()
|
||||
})
|
||||
|
||||
tap.test('exception handling', t => {
|
||||
t.throws(() => calcWidth(0), TypeError, 'throw if feed with non-string input')
|
||||
t.end()
|
||||
|
|
Ładowanie…
Reference in New Issue