jest-watch-typeahead
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -5,4 +5,8 @@ "use strict"; | ||
var _jestRegexUtil = require("jest-regex-util"); | ||
var _prompt = _interopRequireDefault(require("./prompt")); | ||
var _utils = require("../lib/utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -45,3 +49,3 @@ | ||
mode: 'watch', | ||
testPathPattern: value | ||
testPathPattern: (0, _utils.removeTrimmingDots)(value).split('/').map(_jestRegexUtil.escapeStrForRegex).join('/') | ||
}); | ||
@@ -48,0 +52,0 @@ res(); |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.formatTestNameByPattern = exports.highlight = exports.getTerminalWidth = exports.trimAndFormatPath = void 0; | ||
exports.removeTrimmingDots = exports.formatTestNameByPattern = exports.highlight = exports.getTerminalWidth = exports.trimAndFormatPath = void 0; | ||
@@ -20,2 +20,5 @@ var _path = _interopRequireDefault(require("path")); | ||
/* eslint-disable no-param-reassign */ | ||
const TRIMMING_DOTS = '...'; | ||
const ENTER = '⏎'; | ||
const relativePath = (config, testPath) => { | ||
@@ -51,3 +54,3 @@ testPath = _path.default.relative(config.cwd || config.rootDir, testPath); | ||
const dirnameLength = maxLength - 4 - basenameLength; | ||
dirname = `...${dirname.slice(dirname.length - dirnameLength, dirname.length)}`; | ||
dirname = `${TRIMMING_DOTS}${dirname.slice(dirname.length - dirnameLength, dirname.length)}`; | ||
return (0, _slash.default)(_chalk.default.dim(dirname + _path.default.sep) + _chalk.default.bold(basename)); | ||
@@ -57,7 +60,7 @@ } | ||
if (basenameLength + 4 === maxLength) { | ||
return (0, _slash.default)(_chalk.default.dim(`...${_path.default.sep}`) + _chalk.default.bold(basename)); | ||
return (0, _slash.default)(_chalk.default.dim(`${TRIMMING_DOTS}${_path.default.sep}`) + _chalk.default.bold(basename)); | ||
} // can't fit dirname, but can fit trimmed basename | ||
return (0, _slash.default)(_chalk.default.bold(`...${basename.slice(basename.length - maxLength - 4, basename.length)}`)); | ||
return (0, _slash.default)(_chalk.default.bold(`${TRIMMING_DOTS}${basename.slice(basename.length - maxLength - 4, basename.length)}`)); | ||
}; | ||
@@ -72,3 +75,2 @@ | ||
const highlight = (rawPath, filePath, pattern, rootDir) => { | ||
const trim = '...'; | ||
const relativePathHead = './'; | ||
@@ -94,5 +96,5 @@ let regexp; | ||
if (filePath.startsWith(trim)) { | ||
if (filePath.startsWith(TRIMMING_DOTS)) { | ||
offset = rawPath.length - filePath.length; | ||
trimLength = trim.length; | ||
trimLength = TRIMMING_DOTS.length; | ||
} else if (filePath.startsWith(relativePathHead)) { | ||
@@ -112,4 +114,2 @@ offset = rawPath.length - filePath.length; | ||
exports.highlight = highlight; | ||
const DOTS = '...'; | ||
const ENTER = '⏎'; | ||
@@ -141,3 +141,3 @@ const formatTestNameByPattern = (testName, pattern, width) => { | ||
const numberOfTruncatedChars = DOTS.length + inlineTestName.length - width; | ||
const numberOfTruncatedChars = TRIMMING_DOTS.length + inlineTestName.length - width; | ||
const end = Math.max(endPatternIndex - numberOfTruncatedChars, 0); | ||
@@ -148,9 +148,19 @@ const truncatedTestName = inlineTestName.slice(numberOfTruncatedChars); | ||
if (shouldHighlightDots) { | ||
return colorize(DOTS + truncatedTestName, 0, end + DOTS.length); | ||
return colorize(TRIMMING_DOTS + truncatedTestName, 0, end + TRIMMING_DOTS.length); | ||
} | ||
const start = startPatternIndex - numberOfTruncatedChars; | ||
return colorize(DOTS + truncatedTestName, start + DOTS.length, end + DOTS.length); | ||
return colorize(TRIMMING_DOTS + truncatedTestName, start + TRIMMING_DOTS.length, end + TRIMMING_DOTS.length); | ||
}; | ||
exports.formatTestNameByPattern = formatTestNameByPattern; | ||
exports.formatTestNameByPattern = formatTestNameByPattern; | ||
const removeTrimmingDots = value => { | ||
if (value.startsWith(TRIMMING_DOTS)) { | ||
return value.slice(TRIMMING_DOTS.length); | ||
} | ||
return value; | ||
}; | ||
exports.removeTrimmingDots = removeTrimmingDots; |
@@ -5,4 +5,8 @@ "use strict"; | ||
var _jestRegexUtil = require("jest-regex-util"); | ||
var _prompt = _interopRequireDefault(require("./prompt")); | ||
var _utils = require("../lib/utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -45,3 +49,3 @@ | ||
mode: 'watch', | ||
testNamePattern: value | ||
testNamePattern: (0, _jestRegexUtil.escapeStrForRegex)((0, _utils.removeTrimmingDots)(value)) | ||
}); | ||
@@ -48,0 +52,0 @@ res(); |
@@ -37,5 +37,5 @@ "use strict"; | ||
const pluginTester = (Plugin, config = {}) => { | ||
const pluginTester = (Plugin, options = {}) => { | ||
const stdout = { | ||
columns: 80, | ||
columns: (options.stdout || {}).columns || 80, | ||
write: jest.fn() | ||
@@ -46,3 +46,3 @@ }; | ||
stdout, | ||
config | ||
config: options.config | ||
}); | ||
@@ -49,0 +49,0 @@ plugin.apply(jestHooks.getSubscriber()); |
{ | ||
"name": "jest-watch-typeahead", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"main": "build/index.js", | ||
@@ -22,2 +22,3 @@ "author": "Rogelio Guzman <rogelioguzmanh@gmail.com>", | ||
"watch": "babel src -w --ignore **/*.test.js,integration -d build", | ||
"prebuild": "rimraf build", | ||
"build": "babel src --ignore **/*.test.js,integration -d build", | ||
@@ -30,2 +31,3 @@ "prepublish": "yarn build", | ||
"chalk": "^2.4.1", | ||
"jest-regex-util": "^24.9.0", | ||
"jest-watcher": "^24.3.0", | ||
@@ -53,3 +55,4 @@ "slash": "^3.0.0", | ||
"jest": "^24.3.0", | ||
"prettier": "^1.13.7" | ||
"prettier": "^1.13.7", | ||
"rimraf": "^3.0.0" | ||
}, | ||
@@ -56,0 +59,0 @@ "jest": { |
24216
469
7
18
+ Addedjest-regex-util@^24.9.0
+ Addedjest-regex-util@24.9.0(transitive)