-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trim too long assert messages to prevent line overflow
Failing messages need 4 more characters cut.
- Loading branch information
Showing
5 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
TAP version 13 | ||
# Resolving an unknown dependency fails. | ||
not ok 1 The message "Unrecognised dependency: "dummy"." should start with "Unrecognised dependency:". | ||
--- | ||
operator: ok | ||
expected: true | ||
actual: false | ||
at: Test.<anonymous> (/Users/ferdipr/Sources.localized/smartui/gitlab/csui-dependency-installer/test/dependencies.test.js:20:12) | ||
stack: |- | ||
Error: The message "Unrecognised dependency: "dummy"." should start with "Unrecognised dependency:". | ||
at Test.bound [as run] (/Users/ferdipr/Sources/csui-dependency-installer/node_modules/tape/lib/test.js:77:32) | ||
at Immediate.next (/Users/ferdipr/Sources/csui-dependency-installer/node_modules/tape/lib/results.js:81:19) | ||
at runCallback (timers.js:810:20) | ||
... | ||
|
||
1..1 | ||
# tests 1 | ||
# pass 0 | ||
# fail 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
var test = require('tape'); | ||
var stream = require('stream'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var faucet = require('../..'); | ||
|
||
function createFormatter() { | ||
return faucet({ width: 80 }); | ||
} | ||
|
||
function streamifyString(string) { | ||
return new stream.Readable({ | ||
read: function () { | ||
this.push(string); | ||
this.push(null); | ||
} | ||
}); | ||
} | ||
|
||
function stringifyStream(theStream, callback) { | ||
var output = ''; | ||
theStream.on('data', function (chunk) { | ||
output += chunk; | ||
}).on('end', function () { | ||
callback(output); | ||
}); | ||
} | ||
|
||
function getFilePath(name) { | ||
return path.join(__dirname, name + '.tap'); | ||
} | ||
|
||
function checkFormatting(t, name, expectedExcerpt) { | ||
var tapString = fs.readFileSync(getFilePath(name), 'utf-8'); | ||
var formattedStream = streamifyString(tapString).pipe(createFormatter()); | ||
stringifyStream(formattedStream, function (actualOutput) { | ||
var contains = actualOutput.indexOf(expectedExcerpt) > 0; | ||
|
||
t.ok(contains, 'Looking for "' + expectedExcerpt + '" in the "' + name + '" input.'); | ||
|
||
t.end(); | ||
}); | ||
} | ||
|
||
test('A long successful assertion message should be cut.', function (t) { | ||
checkFormatting(t, 'succeeded', 'should start with "Unrecogn...'); | ||
}); | ||
|
||
test('A long failed assertion message should be cut.', function (t) { | ||
checkFormatting(t, 'failed', 'should start with "Unre...'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
TAP version 13 | ||
# Exported dependency names can be resolved. | ||
ok 1 The dependency "csui" should be resolvable. | ||
ok 2 The dependency "esoc" should be resolvable. | ||
# Resolving an unknown dependency fails. | ||
ok 3 The message "Unrecognised dependency: "dummy"." should start with "Unrecognised dependency:". | ||
|
||
1..3 | ||
# tests 3 | ||
# pass 3 | ||
|
||
# ok | ||
|