Skip to content

Commit 01af9e7

Browse files
chore: move/remove deprecation functions (#1402)
1 parent 74acd58 commit 01af9e7

File tree

2 files changed

+17
-42
lines changed

2 files changed

+17
-42
lines changed

src/helpers/deprecation.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,20 @@ function deprecateQuery<QueryFn extends (...args: any) => any>(
3434

3535
return wrapper;
3636
}
37+
38+
const warned: { [functionName: string]: boolean } = {};
39+
40+
// istambul ignore next: Occasionally used
41+
export function printDeprecationWarning(functionName: string) {
42+
if (warned[functionName]) {
43+
return;
44+
}
45+
46+
// eslint-disable-next-line no-console
47+
console.warn(`
48+
Deprecation Warning:
49+
Use of ${functionName} is not recommended and will be deleted in future versions of @testing-library/react-native.
50+
`);
51+
52+
warned[functionName] = true;
53+
}

src/helpers/errors.ts

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ export class ErrorWithStack extends Error {
99
}
1010
}
1111

12-
export const createLibraryNotSupportedError = (error: unknown): Error =>
13-
new Error(
14-
`Currently the only supported library to search by text is "react-native".\n\n${
15-
error instanceof Error ? error.message : ''
16-
}`
17-
);
18-
1912
export const prepareErrorMessage = (
2013
// TS states that error caught in a catch close are of type `unknown`
2114
// most real cases will be `Error`, but better safe than sorry
@@ -71,38 +64,3 @@ export function copyStackTrace(target: unknown, stackTraceSource: Error) {
7164
);
7265
}
7366
}
74-
75-
const warned: { [functionName: string]: boolean } = {};
76-
77-
export function printDeprecationWarning(functionName: string) {
78-
if (warned[functionName]) {
79-
return;
80-
}
81-
82-
// eslint-disable-next-line no-console
83-
console.warn(`
84-
Deprecation Warning:
85-
Use of ${functionName} is not recommended and will be deleted in future versions of @testing-library/react-native.
86-
`);
87-
88-
warned[functionName] = true;
89-
}
90-
91-
export function throwRemovedFunctionError(
92-
functionName: string,
93-
docsRef: string
94-
) {
95-
throw new Error(
96-
`"${functionName}" has been removed.\n\nPlease consult: https://callstack.github.io/react-native-testing-library/docs/${docsRef}`
97-
);
98-
}
99-
100-
export function throwRenamedFunctionError(
101-
functionName: string,
102-
newFunctionName: string
103-
) {
104-
throw new ErrorWithStack(
105-
`The "${functionName}" function has been renamed to "${newFunctionName}". Please replace all occurrences.`,
106-
throwRenamedFunctionError
107-
);
108-
}

0 commit comments

Comments
 (0)