Skip to content

Commit

Permalink
Make patterns private
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonchinn178 committed Mar 3, 2024
1 parent b3f945c commit 1ef878f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/jest-types/src/TestPathPatterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
import {escapePathForRegex, replacePathSepForRegex} from 'jest-regex-util';

export class TestPathPatterns {
constructor(readonly patterns: Array<string>) {}
constructor(private readonly patterns: Array<string>) {}

getPatterns(): Array<string> {
return this.patterns;
}

/**
* Return true if there are any patterns.
Expand Down Expand Up @@ -53,7 +57,7 @@ export class TestPathPatternsExecutor {
private _regexString: string | null = null;

constructor(
readonly patterns: TestPathPatterns,
private readonly testPathPatterns: TestPathPatterns,
private readonly options: TestPathPatternsExecutorOptions,
) {}

Expand All @@ -65,7 +69,7 @@ export class TestPathPatternsExecutor {
const rootDir = this.options.rootDir.replace(/\/*$/, '/');
const rootDirRegex = escapePathForRegex(rootDir);

const regexString = this.patterns.patterns
const regexString = this.getPatterns()
.map(p => {
// absolute paths passed on command line should stay same
if (/^\//.test(p)) {

Check failure on line 75 in packages/jest-types/src/TestPathPatterns.ts

View workflow job for this annotation

GitHub Actions / TypeScript Compatibility

Use 'String#startsWith' method instead
Expand All @@ -91,11 +95,15 @@ export class TestPathPatternsExecutor {
return new RegExp(this.regexString, 'i');
}

getPatterns(): Array<string> {
return this.testPathPatterns.getPatterns();
}

/**
* Return true if there are any patterns.
*/
isSet(): boolean {
return this.patterns.isSet();
return this.testPathPatterns.isSet();
}

/**
Expand Down Expand Up @@ -123,6 +131,6 @@ export class TestPathPatternsExecutor {
* Return a human-friendly version of the pattern regex.
*/
toPretty(): string {
return this.patterns.toPretty();
return this.testPathPatterns.toPretty();
}
}

0 comments on commit 1ef878f

Please sign in to comment.