TestPathPatternPrompt.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _jestWatcher() {
  7. const data = require('jest-watcher');
  8. _jestWatcher = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _defineProperty(obj, key, value) {
  14. if (key in obj) {
  15. Object.defineProperty(obj, key, {
  16. value: value,
  17. enumerable: true,
  18. configurable: true,
  19. writable: true
  20. });
  21. } else {
  22. obj[key] = value;
  23. }
  24. return obj;
  25. }
  26. // TODO: Make underscored props `private`
  27. class TestPathPatternPrompt extends _jestWatcher().PatternPrompt {
  28. constructor(pipe, prompt) {
  29. super(pipe, prompt);
  30. _defineProperty(this, '_searchSources', void 0);
  31. this._entityName = 'filenames';
  32. }
  33. _onChange(pattern, options) {
  34. super._onChange(pattern, options);
  35. this._printPrompt(pattern);
  36. }
  37. _printPrompt(pattern) {
  38. const pipe = this._pipe;
  39. (0, _jestWatcher().printPatternCaret)(pattern, pipe);
  40. (0, _jestWatcher().printRestoredPatternCaret)(
  41. pattern,
  42. this._currentUsageRows,
  43. pipe
  44. );
  45. }
  46. _getMatchedTests(pattern) {
  47. let regex;
  48. try {
  49. regex = new RegExp(pattern, 'i');
  50. } catch {}
  51. let tests = [];
  52. if (regex && this._searchSources) {
  53. this._searchSources.forEach(({searchSource}) => {
  54. tests = tests.concat(searchSource.findMatchingTests(pattern).tests);
  55. });
  56. }
  57. return tests;
  58. }
  59. updateSearchSources(searchSources) {
  60. this._searchSources = searchSources;
  61. }
  62. }
  63. exports.default = TestPathPatternPrompt;