Skip to content

Commit 7667173

Browse files
committed
Merge pull request #92 from fyockm/master
Allow cli-table to determine optimal column width
2 parents ef642ff + bf18dec commit 7667173

10 files changed

Lines changed: 38 additions & 37 deletions

.jshintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"eqnull": true,
23
"expr": true,
34
"jquery": true,
45
"node": true

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language: node_js
22
node_js:
3-
- '0.8'
43
- '0.10'
4+
- '0.11'

lib/log.js

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ print.assertions = function() {
9090
currentTest, test;
9191

9292
table = new Table({
93-
head: ['Module', 'Test', 'Assertion', 'Result'],
94-
colWidths: [40, 40, 40, 8]
93+
head: ['Module', 'Test', 'Assertion', 'Result']
9594
});
9695

9796
data.assertions.forEach(function(data) {
@@ -109,7 +108,7 @@ print.assertions = function() {
109108
test = currentTest = data.test;
110109
}
111110

112-
table.push([module, test, data.message, data.result ? 'ok' : 'fail']);
111+
table.push([module, test, data.message || '', data.result ? 'ok' : 'fail']);
113112
});
114113

115114
log('\nAssertions:\n' + table.toString());
@@ -154,8 +153,7 @@ print.tests = function() {
154153
currentModule, module;
155154

156155
table = new Table({
157-
head: ['Module', 'Test', 'Failed', 'Passed', 'Total'],
158-
colWidths: [40, 40, 8, 8, 8]
156+
head: ['Module', 'Test', 'Failed', 'Passed', 'Total']
159157
});
160158

161159
data.tests.forEach(function(data) {
@@ -173,21 +171,22 @@ print.tests = function() {
173171
};
174172

175173
// truncate file name
176-
function truncfile(code) {
174+
function truncFile(code) {
177175
if (code && code.length > fileColWidth) {
178176
code = '...' + code.slice(code.length - fileColWidth + 3);
179177
}
180178
return code;
181179
}
182180

183181
print.summary = function() {
184-
var table = new Table({
185-
head: ['File', 'Failed', 'Passed', 'Total', 'Runtime'],
186-
colWidths: [fileColWidth + 2, 10, 10, 10, 10]
182+
var table;
183+
184+
table = new Table({
185+
head: ['File', 'Failed', 'Passed', 'Total', 'Runtime']
187186
});
188187

189188
data.summaries.forEach(function(data) {
190-
table.push([truncfile(data.code), data.failed, data.passed, data.total, data.runtime]);
189+
table.push([truncFile(data.code), data.failed, data.passed, data.total, data.runtime]);
191190
});
192191

193192
log('\nSummary:\n' + table.toString());
@@ -198,8 +197,7 @@ print.globalSummary = function() {
198197
data = exports.stats();
199198

200199
table = new Table({
201-
head: ['Files', 'Tests', 'Assertions', 'Failed', 'Passed', 'Runtime'],
202-
colWidths: [12, 12, 12, 12, 12, 12]
200+
head: ['Files', 'Tests', 'Assertions', 'Failed', 'Passed', 'Runtime']
203201
});
204202

205203
table.push([data.files, data.tests, data.assertions, data.failed,
@@ -228,12 +226,16 @@ print.coverage = function() {
228226
if (!data.coverages.length) return;
229227

230228
table = new Table({
231-
head: ['File', 'Statements', 'Branches', 'Functions', 'Lines'],
232-
colWidths: [fileColWidth + 2, 14, 14, 14, 14]
229+
head: ['File', 'Statements', 'Branches', 'Functions', 'Lines']
233230
});
234231

235-
data.coverages.forEach(function(data) {
236-
table.push([truncfile(data.code), getMet(data.statements), getMet(data.branches), getMet(data.functions), getMet(data.lines)]);
232+
data.coverages.forEach(function(coverage) {
233+
table.push([
234+
truncFile(coverage.code),
235+
getMet(coverage.statements),
236+
getMet(coverage.branches),
237+
getMet(coverage.functions),
238+
getMet(coverage.lines)]);
237239
});
238240

239241
log('\nCoverage:\n' + table.toString());
@@ -246,8 +248,7 @@ print.globalCoverage = function() {
246248

247249
coverage = exports.stats().coverage;
248250
table = new Table({
249-
head: ['Files', 'Statements', 'Branches', 'Functions', 'Lines'],
250-
colWidths: [8, 14, 14, 14, 14]
251+
head: ['Files', 'Statements', 'Branches', 'Functions', 'Lines']
251252
});
252253

253254
table.push([

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "qunit",
33
"description": "QUnit testing framework for nodejs",
4-
"version": "0.6.1",
4+
"version": "0.6.2",
55
"author": "Oleg Slobodskoi <oleg008@gmail.com>",
66
"contributors": [
77
{"name": "Jonathan Buchanan"},
@@ -18,18 +18,18 @@
1818
"scripts": {
1919
"test": "make test"
2020
},
21-
"dependencies": {
22-
"underscore": "1.3.3",
23-
"argsparser": "0.0.6",
24-
"cli-table": "0.0.2",
25-
"tracejs": "0.1.4"
21+
"dependencies": {
22+
"underscore": "^1.6.0",
23+
"argsparser": "^0.0.6",
24+
"cli-table": "^0.3.0",
25+
"tracejs": "^0.1.8"
2626
},
2727
"devDependencies": {
28-
"chainer": "0.0.5",
29-
"timekeeper": "0.0.2"
28+
"chainer": "^0.0.5",
29+
"timekeeper": "^0.0.4"
3030
},
3131
"optionalDependencies": {
32-
"istanbul": "0.2.4"
32+
"istanbul": "^0.2.4"
3333
},
3434
"licenses": [
3535
{

test/fixtures/async-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
test('1', 1, function (){
2-
ok(true, "tests intermixing sync and async tests #1");
2+
ok(true, "tests intermixing sync and async tests #1");
33
});
44

55
test('a', 2, function(){
@@ -13,7 +13,7 @@ test('a', 2, function(){
1313
});
1414

1515
test('2', 1, function (){
16-
ok(true, "tests intermixing sync and async tests #2");
16+
ok(true, "tests intermixing sync and async tests #2");
1717
});
1818

1919
test('b', 2, function(){

test/fixtures/child-code-global.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
exports.whereFrom = function() {
2-
return "I was required as global";
2+
return "I was required as global";
33
};
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
exports.whereFrom = function() {
2-
return "I was required as a namespace object";
3-
};
2+
return "I was required as a namespace object";
3+
};

test/fixtures/child-tests-global.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
test("Dependency file required as global", function() {
32
equal(typeof whereFrom, "function");
43
equal(whereFrom(), "I was required as global");

test/fixtures/coverage-code.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ exports.myMethod = function() {
44

55
exports.myAsyncMethod = function(callback) {
66
setTimeout(function() {
7-
callback(123);
7+
callback(123);
88
}, 10000);
99
};
1010

1111
exports.myOtherMethod = function(callback) {
12-
return 321
12+
return 321;
1313
};

test/fixtures/testrunner-code.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ exports.myAsyncMethod = function(callback) {
66
setTimeout(function() {
77
callback(123);
88
}, 100);
9-
};
9+
};

0 commit comments

Comments
 (0)