Skip to content

Commit f18b45c

Browse files
committed
(minor) Move .vowsText and .contextText out of reporters/spec into vows/console
1 parent a813268 commit f18b45c

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

lib/vows/console.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,35 @@ this.error = function (obj) {
9797

9898
return string;
9999
};
100+
101+
this.contextText = function (event) {
102+
return ' ' + event;
103+
};
104+
105+
this.vowText = function (event) {
106+
var buffer = [];
107+
108+
buffer.push(' ' + {
109+
honored: ' ✓ ',
110+
broken: ' ✗ ',
111+
errored: ' ✗ ',
112+
pending: ' - '
113+
}[event.status] + stylize(event.title, ({
114+
honored: 'green',
115+
broken: 'yellow',
116+
errored: 'red',
117+
pending: 'cyan'
118+
})[event.status]));
119+
120+
if (event.status === 'broken') {
121+
buffer.push(' » ' + event.exception);
122+
} else if (event.status === 'errored') {
123+
if (event.exception.type === 'promise') {
124+
buffer.push(' » ' + stylize("An unexpected error was caught: " +
125+
stylize(event.exception.error, 'bold'), 'red'));
126+
} else {
127+
buffer.push(' ' + stylize(event.exception, 'red'));
128+
}
129+
}
130+
return buffer.join('\n');
131+
};

lib/vows/reporters/dot-matrix.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ this.report = function (data) {
3737
}
3838
if (event.status === 'broken') {
3939
puts(stylize('✗', 'yellow'));
40-
messages.push(spec.vowText(event));
40+
messages.push(console.vowText(event));
4141
} else if (event.status === 'errored') {
4242
puts(stylize('✗', 'red'));
43-
messages.push(spec.vowText(event));
43+
messages.push(console.vowText(event));
4444
}
4545
messages.push('');
4646
}

lib/vows/reporters/spec.js

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ this.report = function (data) {
2222
puts('\n♢ ' + stylize(event, 'bold') + '\n');
2323
break;
2424
case 'context':
25-
puts(this.contextText(event));
25+
puts(console.contextText(event));
2626
break;
2727
case 'vow':
28-
puts(this.vowText(event));
28+
puts(console.vowText(event));
2929
break;
3030
case 'end':
3131
sys.print('\n');
@@ -39,38 +39,6 @@ this.report = function (data) {
3939
}
4040
};
4141

42-
this.contextText = function (event) {
43-
return ' ' + event;
44-
};
45-
46-
this.vowText = function (event) {
47-
var buffer = [];
48-
49-
buffer.push(' ' + {
50-
honored: ' ✓ ',
51-
broken: ' ✗ ',
52-
errored: ' ✗ ',
53-
pending: ' - '
54-
}[event.status] + stylize(event.title, ({
55-
honored: 'green',
56-
broken: 'yellow',
57-
errored: 'red',
58-
pending: 'cyan'
59-
})[event.status]));
60-
61-
if (event.status === 'broken') {
62-
buffer.push(' » ' + event.exception);
63-
} else if (event.status === 'errored') {
64-
if (event.exception.type === 'promise') {
65-
buffer.push(' » ' + stylize("An unexpected error was caught: " +
66-
stylize(event.exception.error, 'bold'), 'red'));
67-
} else {
68-
buffer.push(' ' + stylize(event.exception, 'red'));
69-
}
70-
}
71-
return buffer.join('\n');
72-
};
73-
7442
this.print = function (str) {
7543
sys.print(str);
7644
};

lib/vows/reporters/watch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ this.report = function (data) {
2525
if (['honored', 'pending'].indexOf(event.status) === -1) {
2626
if (lastContext !== event.context) {
2727
lastContext = event.context;
28-
puts(spec.contextText(event.context));
28+
puts(console.contextText(event.context));
2929
}
30-
puts(spec.vowText(event));
30+
puts(console.vowText(event));
3131
puts('');
3232
}
3333
break;

0 commit comments

Comments
 (0)