Skip to content

Commit

Permalink
style: update usage info labels
Browse files Browse the repository at this point in the history
  • Loading branch information
NullDivision committed Nov 25, 2020
1 parent bdf0fa5 commit d6aad96
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
20 changes: 11 additions & 9 deletions packages/jest-core/src/FailedTestsInteractiveMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export default class FailedTestsInteractiveMode {
put(key: string): void {
switch (key) {
case 's':
if (this._skippedNum === this._testAssertions.length) break;
if (this._skippedNum === this._testAssertions.length) {
break;
}

this._skippedNum += 1;
// move skipped test to the end
Expand Down Expand Up @@ -68,20 +70,20 @@ export default class FailedTestsInteractiveMode {
}

run(
failedSnapshotTestAssertions: Array<AssertionLocation>,
failedTestAssertions: Array<AssertionLocation>,
updateConfig: RunnerUpdateFunction,
): void {
if (!failedSnapshotTestAssertions.length) return;
if (failedTestAssertions.length === 0) return;

this._testAssertions = [...failedSnapshotTestAssertions];
this._testAssertions = [...failedTestAssertions];
this._countPaths = this._testAssertions.length;
this._updateTestRunnerConfig = updateConfig;
this._isActive = true;
this._run();
}

updateWithResults(results: AggregatedResult): void {
if (!results.snapshot.failure && results.numFailedTests) {
if (!results.snapshot.failure && results.numFailedTests > 0) {
return this._drawUIOverlay();
}

Expand Down Expand Up @@ -115,9 +117,9 @@ export default class FailedTestsInteractiveMode {

let stats = `${pluralize('test', this._countPaths)} reviewed`;

if (this._skippedNum) {
if (this._skippedNum > 0) {
const skippedText = chalk.bold.yellow(
pluralize('snapshot', this._skippedNum) + ' skipped',
pluralize('test', this._skippedNum) + ' skipped',
);

stats = `${stats}, ${skippedText}`;
Expand All @@ -143,9 +145,9 @@ export default class FailedTestsInteractiveMode {
const numRemaining = this._countPaths - numPass - this._skippedNum;
let stats = `${pluralize('test', numRemaining)} remaining`;

if (this._skippedNum) {
if (this._skippedNum > 0) {
const skippedText = chalk.bold.yellow(
pluralize('snapshot', this._skippedNum) + ' skipped',
pluralize('test', this._skippedNum) + ' skipped',
);

stats = `${stats}, ${skippedText}`;
Expand Down
11 changes: 6 additions & 5 deletions packages/jest-core/src/plugins/FailedTestsInteractive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export default class FailedTestsInteractivePlugin extends BaseWatchPlugin {

apply(hooks: JestHookSubscriber): void {
hooks.onTestRunComplete(results => {
this._failedTestAssertions = this.getFailedSnapshotTestAssertions(
results,
);
this._failedTestAssertions = this.getFailedTestAssertions(results);

if (this._manager.isActive()) this._manager.updateWithResults(results);
});
Expand All @@ -48,7 +46,10 @@ export default class FailedTestsInteractivePlugin extends BaseWatchPlugin {
updateConfigAndRun: UpdateConfigCallback,
): Promise<void> {
return new Promise(resolve => {
if (!this._failedTestAssertions || this._failedTestAssertions.length === 0) {
if (
!this._failedTestAssertions ||
this._failedTestAssertions.length === 0
) {
resolve();
return;
}
Expand All @@ -67,7 +68,7 @@ export default class FailedTestsInteractivePlugin extends BaseWatchPlugin {
});
}

private getFailedSnapshotTestAssertions(
private getFailedTestAssertions(
results: AggregatedResult,
): Array<AssertionLocation> {
const failedTestPaths: Array<AssertionLocation> = [];
Expand Down

0 comments on commit d6aad96

Please sign in to comment.