[Pkg-javascript-commits] [node-tap-mocha-reporter] 70/137: classic reporter: calculate unicode string lengths properly
Bastien Roucariès
rouca at moszumanska.debian.org
Thu Sep 7 09:49:27 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-tap-mocha-reporter.
commit 03881f6a5a8083d95101671fcbd1070ae3f92dc2
Author: isaacs <i at izs.me>
Date: Sat Jun 27 11:53:11 2015 -0700
classic reporter: calculate unicode string lengths properly
---
lib/reporters/classic.js | 13 +++++++------
package.json | 3 ++-
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/lib/reporters/classic.js b/lib/reporters/classic.js
index 03dde82..e15e29d 100644
--- a/lib/reporters/classic.js
+++ b/lib/reporters/classic.js
@@ -9,6 +9,7 @@ var Base = require('./base')
, ms = require('../ms.js')
, diff = require('diff')
, utils = require('../utils.js')
+ , uclen = require('unicode-length').get
function hasOwnProperty (obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key)
@@ -144,8 +145,8 @@ function doDiff (found, wanted, palette) {
//console.error(patch)
var width = 0
patch = patch.split('\n').map(function (line, index) {
- if (line.length > width)
- width = Math.min(maxLen, line.length)
+ if (uclen(line) > width)
+ width = Math.min(maxLen, uclen(line))
if (line.match(/^\=+$/) ||
line === '\\ No newline at end of file')
return null
@@ -154,8 +155,8 @@ function doDiff (found, wanted, palette) {
}).filter(function (line, i) {
return line && i > 4
}).map(function (line) {
- if (line.length < width)
- line += new Array(width - line.length + 1).join(' ')
+ if (uclen(line) < width)
+ line += new Array(width - uclen(line) + 1).join(' ')
return line
}).map(function (line) {
if (line.charAt(0) === '+')
@@ -244,7 +245,7 @@ function Classic (runner) {
var len = 60
var title = suite.title || '(unnamed)'
var num = pass + '/' + total
- var dots = len - title.length - num.length - 2
+ var dots = len - uclen(title) - uclen(num) - 2
if (dots < 3)
dots = 3
dots = ' ' + new Array(dots).join('.') + ' '
@@ -320,7 +321,7 @@ function Classic (runner) {
grandTotal ++
var t = test.result
if (fancy && currentSuite) {
- var max = 57 - currentSuite.title.length
+ var max = 57 - uclen(currentSuite.title)
if (max < 3)
max = 3
diff --git a/package.json b/package.json
index 68eedf8..5ebf3bf 100644
--- a/package.json
+++ b/package.json
@@ -23,7 +23,8 @@
"glob": "^5.0.5",
"js-yaml": "^3.3.1",
"supports-color": "^1.3.1",
- "tap-parser": "^1.0.4"
+ "tap-parser": "^1.0.4",
+ "unicode-length": "^1.0.0"
},
"devDependencies": {
"tap": "^1.0.0-beta"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-tap-mocha-reporter.git
More information about the Pkg-javascript-commits
mailing list