Skip to content

Commit

Permalink
Attempt at reproducing an another store reading bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rricard committed Sep 28, 2016
1 parent a161d0e commit 4b84654
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/mutationResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,51 @@ describe('mutation results', () => {
});
});

it('does not make next queries fail if a mutation fails', (done) => {
const obsHandle = setupObsHandle({
request: { query: mutation },
result: {errors: [new Error('mock error')]},
}, {
request: { query },
result,
});

obsHandle.subscribe({
next() {
client.mutate({
mutation,
updateQueries: {
todoList: (prev, options) => {
const mResult = options.mutationResult as any;
const state = clonedeep(prev) as any;
state.todoList.todos.unshift(mResult.data.createTodo);
return state;
},
},
})
.then(
() => done(new Error('Mutation should have failed')),
() => client.mutate({
mutation,
updateQueries: {
todoList: (prev, options) => {
const mResult = options.mutationResult as any;
const state = clonedeep(prev) as any;
state.todoList.todos.unshift(mResult.data.createTodo);
return state;
},
},
}),
)
.then(
() => done(new Error('Mutation should have failed')),
() => obsHandle.refetch(),
)
.then(() => done(), done);
},
});
});

it('error handling in reducer functions', () => {
const oldError = console.error;
const errors: any[] = [];
Expand Down

0 comments on commit 4b84654

Please sign in to comment.