From 1ef878ff781021d6d9b8fec5e8cdc259e04648af Mon Sep 17 00:00:00 2001 From: Brandon Chinn Date: Sat, 2 Mar 2024 23:07:07 -0800 Subject: [PATCH] Make patterns private --- packages/jest-types/src/TestPathPatterns.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/jest-types/src/TestPathPatterns.ts b/packages/jest-types/src/TestPathPatterns.ts index e32d27a4adf3..3729bc229a0a 100644 --- a/packages/jest-types/src/TestPathPatterns.ts +++ b/packages/jest-types/src/TestPathPatterns.ts @@ -8,7 +8,11 @@ import {escapePathForRegex, replacePathSepForRegex} from 'jest-regex-util'; export class TestPathPatterns { - constructor(readonly patterns: Array) {} + constructor(private readonly patterns: Array) {} + + getPatterns(): Array { + return this.patterns; + } /** * Return true if there are any patterns. @@ -53,7 +57,7 @@ export class TestPathPatternsExecutor { private _regexString: string | null = null; constructor( - readonly patterns: TestPathPatterns, + private readonly testPathPatterns: TestPathPatterns, private readonly options: TestPathPatternsExecutorOptions, ) {} @@ -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)) { @@ -91,11 +95,15 @@ export class TestPathPatternsExecutor { return new RegExp(this.regexString, 'i'); } + getPatterns(): Array { + return this.testPathPatterns.getPatterns(); + } + /** * Return true if there are any patterns. */ isSet(): boolean { - return this.patterns.isSet(); + return this.testPathPatterns.isSet(); } /** @@ -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(); } }