summaryrefslogtreecommitdiff
path: root/spec/frontend/lib/utils
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-31 15:08:50 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-31 15:08:50 +0000
commitccab6fb4df8bc12220334618e56d911c4d0e447c (patch)
treea8c7bb66fb4c36c97e7e1b4f27744fcd93c3bcf3 /spec/frontend/lib/utils
parent820c5f6d5c816ba4b742f2ae2e08cc548314531a (diff)
downloadgitlab-ce-ccab6fb4df8bc12220334618e56d911c4d0e447c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib/utils')
-rw-r--r--spec/frontend/lib/utils/error_message_spec.js35
1 files changed, 20 insertions, 15 deletions
diff --git a/spec/frontend/lib/utils/error_message_spec.js b/spec/frontend/lib/utils/error_message_spec.js
index 54c630b8ba0..d55a6de06c3 100644
--- a/spec/frontend/lib/utils/error_message_spec.js
+++ b/spec/frontend/lib/utils/error_message_spec.js
@@ -1,4 +1,4 @@
-import { parseErrorMessage, USER_FACING_ERROR_MESSAGE_PREFIX } from '~/lib/utils/error_message';
+import { parseErrorMessage } from '~/lib/utils/error_message';
const defaultErrorMessage = 'Default error message';
const errorMessage = 'Returned error message';
@@ -10,13 +10,18 @@ const generateErrorWithMessage = (message) => {
};
describe('parseErrorMessage', () => {
+ const ufErrorPrefix = 'Foo:';
+ beforeEach(() => {
+ gon.uf_error_prefix = ufErrorPrefix;
+ });
+
it.each`
- error | expectedResult
- ${`${USER_FACING_ERROR_MESSAGE_PREFIX} ${errorMessage}`} | ${errorMessage}
- ${`${errorMessage} ${USER_FACING_ERROR_MESSAGE_PREFIX}`} | ${defaultErrorMessage}
- ${errorMessage} | ${defaultErrorMessage}
- ${undefined} | ${defaultErrorMessage}
- ${''} | ${defaultErrorMessage}
+ error | expectedResult
+ ${`${ufErrorPrefix} ${errorMessage}`} | ${errorMessage}
+ ${`${errorMessage} ${ufErrorPrefix}`} | ${defaultErrorMessage}
+ ${errorMessage} | ${defaultErrorMessage}
+ ${undefined} | ${defaultErrorMessage}
+ ${''} | ${defaultErrorMessage}
`(
'properly parses "$error" error object and returns "$expectedResult"',
({ error, expectedResult }) => {
@@ -26,14 +31,14 @@ describe('parseErrorMessage', () => {
);
it.each`
- error | defaultMessage | expectedResult
- ${undefined} | ${defaultErrorMessage} | ${defaultErrorMessage}
- ${''} | ${defaultErrorMessage} | ${defaultErrorMessage}
- ${{}} | ${defaultErrorMessage} | ${defaultErrorMessage}
- ${generateErrorWithMessage(errorMessage)} | ${undefined} | ${''}
- ${generateErrorWithMessage(`${USER_FACING_ERROR_MESSAGE_PREFIX} ${errorMessage}`)} | ${undefined} | ${errorMessage}
- ${generateErrorWithMessage(errorMessage)} | ${''} | ${''}
- ${generateErrorWithMessage(`${USER_FACING_ERROR_MESSAGE_PREFIX} ${errorMessage}`)} | ${''} | ${errorMessage}
+ error | defaultMessage | expectedResult
+ ${undefined} | ${defaultErrorMessage} | ${defaultErrorMessage}
+ ${''} | ${defaultErrorMessage} | ${defaultErrorMessage}
+ ${{}} | ${defaultErrorMessage} | ${defaultErrorMessage}
+ ${generateErrorWithMessage(errorMessage)} | ${undefined} | ${''}
+ ${generateErrorWithMessage(`${ufErrorPrefix} ${errorMessage}`)} | ${undefined} | ${errorMessage}
+ ${generateErrorWithMessage(errorMessage)} | ${''} | ${''}
+ ${generateErrorWithMessage(`${ufErrorPrefix} ${errorMessage}`)} | ${''} | ${errorMessage}
`(
'properly handles the edge case of error="$error" and defaultMessage="$defaultMessage"',
({ error, defaultMessage, expectedResult }) => {