Commit 4e2f8ef1 authored by Denys Mishunov's avatar Denys Mishunov

Expect GraphQL errors to be an Array

parent ac4c5ded
...@@ -138,7 +138,7 @@ export default { ...@@ -138,7 +138,7 @@ export default {
variables: { id: this.snippet.id }, variables: { id: this.snippet.id },
}) })
.then(({ data }) => { .then(({ data }) => {
if (data?.destroySnippet?.errors) { if (data?.destroySnippet?.errors.length) {
throw new Error(data?.destroySnippet?.errors[0]); throw new Error(data?.destroySnippet?.errors[0]);
} }
this.isDeleting = false; this.isDeleting = false;
......
...@@ -32,7 +32,9 @@ describe('Snippet header component', () => { ...@@ -32,7 +32,9 @@ describe('Snippet header component', () => {
const errorMsg = 'Foo bar'; const errorMsg = 'Foo bar';
const err = { message: errorMsg }; const err = { message: errorMsg };
const resolveMutate = jest.fn(() => Promise.resolve({ data: {} })); const resolveMutate = jest.fn(() =>
Promise.resolve({ data: { destroySnippet: { errors: [] } } }),
);
const rejectMutation = jest.fn(() => Promise.reject(err)); const rejectMutation = jest.fn(() => Promise.reject(err));
const mutationTypes = { const mutationTypes = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment