More tests against snapshots #4

pull/6/head
Amio 2018-07-19 14:39:31 +08:00
rodzic 20c3654495
commit f0294bfbcf
3 zmienionych plików z 26 dodań i 2 usunięć

Wyświetl plik

@ -10,6 +10,7 @@
"lint": "standard",
"bench": "node bench/index.js",
"preview": "node preview/serve.js",
"snaptests": "TAP_SNAPSHOT=1 npm test",
"pretest": "npm run lint",
"test": "tap test/*.spec.js --reporter spec --coverage"
},

Wyświetl plik

@ -0,0 +1,18 @@
/* IMPORTANT
* This snapshot file is auto-generated, but designed for humans.
* It should be checked into source control and tracked carefully.
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/calc-text-width.spec.js TAP calc width for "npm" > result is correct 1`] = `
24.9
`
exports[`test/calc-text-width.spec.js TAP calc width for unicode > result is correct 1`] = `
56
`
exports[`test/calc-text-width.spec.js TAP calc width for emojis > result is correct 1`] = `
33.6
`

Wyświetl plik

@ -9,12 +9,17 @@ tap.test('basic functions', t => {
})
tap.test('calc width for "npm"', t => {
t.is(calcWidth('npm'), 24.9, 'result is correct value')
t.matchSnapshot(calcWidth('npm'), 'result is correct')
t.end()
})
tap.test('calc width for unicode', t => {
t.is(calcWidth('壹佰贰拾叁'), 56, 'result is correct value')
t.matchSnapshot(calcWidth('壹佰贰拾叁'), 'result is correct')
t.end()
})
tap.test('calc width for emojis', t => {
t.matchSnapshot(calcWidth('💩🤱🦄', true), 'result is correct')
t.end()
})