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