-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2813 from postmanlabs/feature/cli-reporter-verbos…
…e-body Extended CLI reporter to show more request response info in verbose mode
- Loading branch information
Showing
7 changed files
with
228 additions
and
88 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
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 |
---|---|---|
@@ -1,52 +1,49 @@ | ||
const _ = require('lodash'), | ||
|
||
isDoubleByte = function (str) { | ||
for (var i = 0, n = str.length; i < n; i++) { | ||
if (str.charCodeAt(i) > 255) { return true; } | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
/* eslint-disable */ | ||
/** | ||
* @attribution https://github.com/lodash/lodash/issues/2240#issuecomment-418820848 | ||
*/ | ||
const flattenKeys = (obj, path = []) => | ||
!_.isObject(obj) | ||
? { [path.join('.')]: obj } | ||
: _.reduce(obj, (cum, next, key) => _.merge(cum, flattenKeys(next, [...path, key])), {}); | ||
/* eslint-enable */ | ||
|
||
describe('unicode handling of cli symbol utility module', function () { | ||
var cliUtilsSymbols = require('../../lib/reporters/cli/cli-utils-symbols.js'); | ||
|
||
it('should revert to text alternatives when disableUnicode parameter is set to true', function () { | ||
var symbols = cliUtilsSymbols(true); | ||
|
||
expect(symbols).to.eql({ | ||
console: { | ||
top: '-', | ||
middle: '|', | ||
bottom: '-' | ||
}, | ||
dot: '.', | ||
folder: 'Folder', | ||
root: 'Root', | ||
sub: 'Sub-folder', | ||
ok: 'Pass', | ||
error: 'Fail' | ||
}); | ||
let cliUtilsSymbols = require('../../lib/reporters/cli/cli-utils-symbols.js'); | ||
|
||
it('should have three symbol classes', function () { | ||
expect(cliUtilsSymbols(true)).to.be.an('object'); | ||
expect(cliUtilsSymbols(false)).to.be.an('object'); | ||
}); | ||
|
||
it('should provide the platform-specific default symbol map when no options are passed', function () { | ||
var symbols = cliUtilsSymbols(), | ||
isWin = (/^win/).test(process.platform); | ||
|
||
expect(symbols).to.eql(isWin ? { | ||
console: { | ||
top: '\u250C', | ||
middle: '\u2502', | ||
bottom: '\u2514' | ||
}, | ||
dot: '.', | ||
folder: '□', | ||
root: '→', | ||
sub: '└', | ||
ok: '√', | ||
error: '×' | ||
} : { | ||
console: { | ||
top: '┌', | ||
middle: '│', | ||
bottom: '└' | ||
}, | ||
dot: '.', | ||
folder: '❏', | ||
root: '→', | ||
sub: '↳', | ||
ok: '✓', | ||
error: '✖' | ||
}); | ||
it('should have appropriate fallback for unicode', function () { | ||
let symbol = cliUtilsSymbols(true), | ||
fallback = cliUtilsSymbols(false), | ||
|
||
flattenedSymbols = flattenKeys(symbol), | ||
flattenedPlainSymbols = flattenKeys(fallback); | ||
|
||
expect(flattenedSymbols).to.contain.keys(flattenedPlainSymbols); | ||
}); | ||
|
||
it('should not have unicode when not requested', function () { | ||
let fallbackSymbols = cliUtilsSymbols(true), | ||
flattenedPlainSymbols = flattenKeys(fallbackSymbols); | ||
|
||
// first compute all double byte checking | ||
for (const [key, value] of Object.entries(flattenedPlainSymbols)) { | ||
// @todo make the assertion better so that failure here says what exactly went wrong | ||
expect(isDoubleByte(value)).to.eql(false, key); | ||
} | ||
}); | ||
}); |
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
Oops, something went wrong.