UNPKG

2.03 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', {
4 value: true
5});
6exports.default = void 0;
7
8function _jestWatcher() {
9 const data = require('jest-watcher');
10
11 _jestWatcher = function () {
12 return data;
13 };
14
15 return data;
16}
17
18function _TestPathPatternPrompt() {
19 const data = _interopRequireDefault(require('../TestPathPatternPrompt'));
20
21 _TestPathPatternPrompt = function () {
22 return data;
23 };
24
25 return data;
26}
27
28function _activeFiltersMessage() {
29 const data = _interopRequireDefault(require('../lib/activeFiltersMessage'));
30
31 _activeFiltersMessage = function () {
32 return data;
33 };
34
35 return data;
36}
37
38function _interopRequireDefault(obj) {
39 return obj && obj.__esModule ? obj : {default: obj};
40}
41
42function _defineProperty(obj, key, value) {
43 if (key in obj) {
44 Object.defineProperty(obj, key, {
45 value: value,
46 enumerable: true,
47 configurable: true,
48 writable: true
49 });
50 } else {
51 obj[key] = value;
52 }
53 return obj;
54}
55
56class TestPathPatternPlugin extends _jestWatcher().BaseWatchPlugin {
57 constructor(options) {
58 super(options);
59
60 _defineProperty(this, '_prompt', void 0);
61
62 _defineProperty(this, 'isInternal', void 0);
63
64 this._prompt = new (_jestWatcher().Prompt)();
65 this.isInternal = true;
66 }
67
68 getUsageInfo() {
69 return {
70 key: 'p',
71 prompt: 'filter by a filename regex pattern'
72 };
73 }
74
75 onKey(key) {
76 this._prompt.put(key);
77 }
78
79 run(globalConfig, updateConfigAndRun) {
80 return new Promise((res, rej) => {
81 const testPathPatternPrompt = new (_TestPathPatternPrompt().default)(
82 this._stdout,
83 this._prompt
84 );
85 testPathPatternPrompt.run(
86 value => {
87 updateConfigAndRun({
88 mode: 'watch',
89 testPathPattern: value
90 });
91 res();
92 },
93 rej,
94 {
95 header: (0, _activeFiltersMessage().default)(globalConfig)
96 }
97 );
98 });
99 }
100}
101
102var _default = TestPathPatternPlugin;
103exports.default = _default;