Skip to content

Commit

Permalink
Fix filters (#3392)
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeliog authored and cpojer committed Apr 27, 2017
1 parent c979516 commit dd937ae
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
9 changes: 7 additions & 2 deletions packages/jest-cli/src/TestNamePatternPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,22 @@ module.exports = class TestNamePatternPrompt {
_cachedTestResults: Array<TestResult>;
_pipe: stream$Writable | tty$WriteStream;
_prompt: Prompt;
_currentUsageRows: number;

constructor(pipe: stream$Writable | tty$WriteStream, prompt: Prompt) {
this._pipe = pipe;
this._prompt = prompt;
this._currentUsageRows = usageRows;
}

run(onSuccess: Function, onCancel: Function, options?: {header: string}) {
this._pipe.write(ansiEscapes.cursorHide);
this._pipe.write(ansiEscapes.clearScreen);
if (options && options.header) {
this._pipe.write(options.header);
this._pipe.write(options.header + '\n');
this._currentUsageRows = usageRows + options.header.split('\n').length;
} else {
this._currentUsageRows = usageRows;
}
this._pipe.write(usage());
this._pipe.write(ansiEscapes.cursorShow);
Expand Down Expand Up @@ -103,7 +108,7 @@ module.exports = class TestNamePatternPrompt {
}

this._pipe.write(
ansiEscapes.cursorTo(stringLength(inputText), usageRows - 1),
ansiEscapes.cursorTo(stringLength(inputText), this._currentUsageRows - 1),
);
this._pipe.write(ansiEscapes.cursorRestorePosition);
}
Expand Down
9 changes: 7 additions & 2 deletions packages/jest-cli/src/TestPathPatternPrompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,22 @@ module.exports = class TestPathPatternPrompt {
_pipe: stream$Writable | tty$WriteStream;
_prompt: Prompt;
_searchSources: SearchSources;
_currentUsageRows: number;

constructor(pipe: stream$Writable | tty$WriteStream, prompt: Prompt) {
this._pipe = pipe;
this._prompt = prompt;
this._currentUsageRows = usageRows;
}

run(onSuccess: Function, onCancel: Function, options?: {header: string}) {
this._pipe.write(ansiEscapes.cursorHide);
this._pipe.write(ansiEscapes.clearScreen);
if (options && options.header) {
this._pipe.write(options.header);
this._pipe.write(options.header + '\n');
this._currentUsageRows = usageRows + options.header.split('\n').length;
} else {
this._currentUsageRows = usageRows;
}
this._pipe.write(usage());
this._pipe.write(ansiEscapes.cursorShow);
Expand Down Expand Up @@ -130,7 +135,7 @@ module.exports = class TestPathPatternPrompt {
}

this._pipe.write(
ansiEscapes.cursorTo(stringLength(inputText), usageRows - 1),
ansiEscapes.cursorTo(stringLength(inputText), this._currentUsageRows - 1),
);
this._pipe.write(ansiEscapes.cursorRestorePosition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ exports[`Watch mode flows Pressing "c" clears the filters 1`] = `
"[MOCK - cursorHide]
[MOCK - clearScreen]
Pattern Mode Usage
› Press Esc to exit pattern mode.
› Press Enter to apply pattern to all filenames.
Expand Down Expand Up @@ -358,7 +356,7 @@ Pattern Mode Usage
Start typing to filter by a test name regex pattern.
[MOCK - cursorTo(11, 5)]
[MOCK - cursorTo(11, 7)]
[MOCK - cursorRestorePosition]"
`;

Expand All @@ -383,7 +381,7 @@ Pattern Mode Usage
Start typing to filter by a filename regex pattern.
[MOCK - cursorTo(11, 5)]
[MOCK - cursorTo(11, 7)]
[MOCK - cursorRestorePosition]"
`;

Expand All @@ -408,7 +406,7 @@ Pattern Mode Usage
Start typing to filter by a filename regex pattern.
[MOCK - cursorTo(11, 5)]
[MOCK - cursorTo(11, 7)]
[MOCK - cursorRestorePosition]"
`;

Expand All @@ -433,7 +431,7 @@ Pattern Mode Usage
Start typing to filter by a test name regex pattern.
[MOCK - cursorTo(11, 5)]
[MOCK - cursorTo(11, 7)]
[MOCK - cursorRestorePosition]"
`;

Expand All @@ -458,6 +456,6 @@ Pattern Mode Usage
Start typing to filter by a test name regex pattern.
[MOCK - cursorTo(11, 5)]
[MOCK - cursorTo(11, 7)]
[MOCK - cursorRestorePosition]"
`;
4 changes: 2 additions & 2 deletions packages/jest-cli/src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ const watch = (
startRun();
},
onCancelPatternPrompt,
{header: activeFilters(argv) + '\n'},
{header: activeFilters(argv)},
);
break;
case KEYS.T:
Expand All @@ -224,7 +224,7 @@ const watch = (
startRun();
},
onCancelPatternPrompt,
{header: activeFilters(argv) + '\n'},
{header: activeFilters(argv)},
);
break;
case KEYS.QUESTION_MARK:
Expand Down

0 comments on commit dd937ae

Please sign in to comment.