Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/boards/cache_updates_spec.js')
-rw-r--r--spec/frontend/boards/cache_updates_spec.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/frontend/boards/cache_updates_spec.js b/spec/frontend/boards/cache_updates_spec.js
new file mode 100644
index 00000000000..bc661f20451
--- /dev/null
+++ b/spec/frontend/boards/cache_updates_spec.js
@@ -0,0 +1,37 @@
+import * as Sentry from '@sentry/browser';
+import { setError } from '~/boards/graphql/cache_updates';
+import { defaultClient } from '~/graphql_shared/issuable_client';
+import setErrorMutation from '~/boards/graphql/client/set_error.mutation.graphql';
+
+describe('setError', () => {
+ let sentryCaptureExceptionSpy;
+ const errorMessage = 'Error';
+ const error = new Error(errorMessage);
+
+ beforeEach(() => {
+ jest.spyOn(defaultClient, 'mutate').mockResolvedValue();
+ sentryCaptureExceptionSpy = jest.spyOn(Sentry, 'captureException');
+ });
+
+ it('calls setErrorMutation and capture Sentry error', () => {
+ setError({ message: errorMessage, error });
+
+ expect(defaultClient.mutate).toHaveBeenCalledWith({
+ mutation: setErrorMutation,
+ variables: { error: errorMessage },
+ });
+
+ expect(sentryCaptureExceptionSpy).toHaveBeenCalledWith(error);
+ });
+
+ it('does not capture Sentry error when captureError is false', () => {
+ setError({ message: errorMessage, error, captureError: false });
+
+ expect(defaultClient.mutate).toHaveBeenCalledWith({
+ mutation: setErrorMutation,
+ variables: { error: errorMessage },
+ });
+
+ expect(sentryCaptureExceptionSpy).not.toHaveBeenCalled();
+ });
+});