Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions packages/apollo-client/src/__tests__/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ describe('client', () => {
if (e === expectedError) {
done();
} else {
done(e);
done.fail(e);
}
};
process.removeListener('uncaughtException', oldHandler);
Expand Down Expand Up @@ -656,7 +656,7 @@ describe('client', () => {
if (e === expectedError) {
done();
} else {
done(e);
done.fail(e);
}
};
process.removeListener('uncaughtException', oldHandler);
Expand Down Expand Up @@ -685,7 +685,7 @@ describe('client', () => {
const handle = client.watchQuery({ query });
handle.subscribe({
next() {
done(new Error('did not expect next to be called'));
done.fail(new Error('did not expect next to be called'));
},
error() {
throw expectedError;
Expand Down Expand Up @@ -1242,11 +1242,11 @@ describe('client', () => {
done();
})
.catch(err => {
done(err);
done.fail(err);
});
},
error(err) {
done(err);
done.fail(err);
},
});
});
Expand Down Expand Up @@ -1512,15 +1512,13 @@ describe('client', () => {
request: { query },
result: { data: networkFetch },
});

const client = new ApolloClient({
link,
cache: new InMemoryCache({ addTypename: false }),
});

client.writeQuery({
query,
data: initialData,
});
client.writeQuery({ query, data: initialData });

const obs = client.watchQuery({
query,
Expand All @@ -1530,7 +1528,7 @@ describe('client', () => {
subscribeAndCount(done, obs, (handleCount, result) => {
if (handleCount === 1) {
expect(result.data).toEqual(initialData);
} else if (handleCount === 2) {
} else if (handleCount === 3) {
expect(result.data).toEqual(networkFetch);
done();
}
Expand Down Expand Up @@ -1649,7 +1647,9 @@ describe('client', () => {
}
if (handleCount === 2) {
handleCalled = true;
done(new Error('Handle should never be called on standby query'));
done.fail(
new Error('Handle should never be called on standby query'),
);
}
});
});
Expand Down Expand Up @@ -1845,7 +1845,7 @@ describe('client', () => {
client
.mutate({ mutation })
.then(_ => {
done(new Error('Returned a result when it should not have.'));
done.fail(new Error('Returned a result when it should not have.'));
})
.catch((error: ApolloError) => {
expect(error.networkError).toBeDefined();
Expand Down Expand Up @@ -1882,7 +1882,7 @@ describe('client', () => {
client
.mutate({ mutation })
.then(_ => {
done(new Error('Returned a result when it should not have.'));
done.fail(new Error('Returned a result when it should not have.'));
})
.catch((error: ApolloError) => {
expect(error.graphQLErrors).toBeDefined();
Expand Down Expand Up @@ -2009,7 +2009,7 @@ describe('client', () => {
).toBe(1);
mutatePromise
.then(_ => {
done(new Error('Returned a result when it should not have.'));
done.fail(new Error('Returned a result when it should not have.'));
})
.catch((_: ApolloError) => {
expect(
Expand Down Expand Up @@ -2417,7 +2417,7 @@ describe('@connect', () => {
subscribeAndCount(done, obs, (handleCount, result) => {
if (handleCount === 1) {
expect(result.data).toEqual(initialData);
} else if (handleCount === 2) {
} else if (handleCount === 3) {
expect(result.data).toEqual(networkFetch);
done();
}
Expand Down
40 changes: 26 additions & 14 deletions packages/apollo-client/src/__tests__/fetchMore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,11 @@ describe('fetchMore on an observable query', () => {
done();
break;
default:
done(new Error('`next` called too many times'));
done.fail(new Error('`next` called too many times'));
}
},
error: error => done(error),
complete: () => done(new Error('Should not have completed')),
error: error => done.fail(error),
complete: () => done.fail(new Error('Should not have completed')),
});
});

Expand Down Expand Up @@ -414,7 +414,9 @@ describe('fetchMore on an observable query', () => {
expect((data as any).entry.comments.length).toBe(10);
break;
default:
done(new Error('`next` called when it wasn’t supposed to be.'));
done.fail(
new Error('`next` called when it wasn’t supposed to be.'),
);
}
},
error: error => {
Expand All @@ -425,14 +427,18 @@ describe('fetchMore on an observable query', () => {
done();
break;
default:
done(new Error('`error` called when it wasn’t supposed to be.'));
done.fail(
new Error('`error` called when it wasn’t supposed to be.'),
);
}
} catch (error) {
done(error);
done.fail(error);
}
},
complete: () =>
done(new Error('`complete` called when it wasn’t supposed to be.')),
done.fail(
new Error('`complete` called when it wasn’t supposed to be.'),
),
});
});
});
Expand Down Expand Up @@ -612,11 +618,11 @@ describe('fetchMore on an observable query with connection', () => {
done();
break;
default:
done(new Error('`next` called too many times'));
done.fail(new Error('`next` called too many times'));
}
},
error: error => done(error),
complete: () => done(new Error('Should not have completed')),
error: error => done.fail(error),
complete: () => done.fail(new Error('Should not have completed')),
});
});

Expand Down Expand Up @@ -665,7 +671,9 @@ describe('fetchMore on an observable query with connection', () => {
expect((data as any).entry.comments.length).toBe(10);
break;
default:
done(new Error('`next` called when it wasn’t supposed to be.'));
done.fail(
new Error('`next` called when it wasn’t supposed to be.'),
);
}
},
error: error => {
Expand All @@ -676,14 +684,18 @@ describe('fetchMore on an observable query with connection', () => {
done();
break;
default:
done(new Error('`error` called when it wasn’t supposed to be.'));
done.fail(
new Error('`error` called when it wasn’t supposed to be.'),
);
}
} catch (error) {
done(error);
done.fail(error);
}
},
complete: () =>
done(new Error('`complete` called when it wasn’t supposed to be.')),
done.fail(
new Error('`complete` called when it wasn’t supposed to be.'),
),
});
});
});
20 changes: 10 additions & 10 deletions packages/apollo-client/src/__tests__/mutationResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ describe('mutation results', () => {
},
})
.then(
() => done(new Error('Mutation should have failed')),
() => done.fail(new Error('Mutation should have failed')),
() =>
client.mutate({
mutation,
Expand All @@ -570,10 +570,10 @@ describe('mutation results', () => {
}),
)
.then(
() => done(new Error('Mutation should have failed')),
() => done.fail(new Error('Mutation should have failed')),
() => obsHandle.refetch(),
)
.then(() => done(), done);
.then(() => done(), done.fail);
},
});
});
Expand Down Expand Up @@ -690,7 +690,7 @@ describe('mutation results', () => {

const firstSubs = watchedQuery.subscribe({
next: () => null,
error: done,
error: done.fail,
});

// Cancel the query right away!
Expand Down Expand Up @@ -800,7 +800,7 @@ describe('mutation results', () => {
});
done();
})
.catch(done);
.catch(done.fail);
});

it('allows mutations with default values', done => {
Expand Down Expand Up @@ -878,7 +878,7 @@ describe('mutation results', () => {
});
done();
})
.catch(done);
.catch(done.fail);
});

it('will pass null to the network interface when provided', done => {
Expand Down Expand Up @@ -957,7 +957,7 @@ describe('mutation results', () => {
});
done();
})
.catch(done);
.catch(done.fail);
});

describe('store transaction updater', () => {
Expand Down Expand Up @@ -1192,7 +1192,7 @@ describe('mutation results', () => {
},
})
.then(
() => done(new Error('Mutation should have failed')),
() => done.fail(new Error('Mutation should have failed')),
() =>
client.mutate({
mutation,
Expand Down Expand Up @@ -1228,10 +1228,10 @@ describe('mutation results', () => {
}),
)
.then(
() => done(new Error('Mutation should have failed')),
() => done.fail(new Error('Mutation should have failed')),
() => obsHandle.refetch(),
)
.then(() => done(), done);
.then(() => done(), done.fail);
},
});
});
Expand Down
16 changes: 8 additions & 8 deletions packages/apollo-client/src/__tests__/optimistic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1175,10 +1175,10 @@ describe('optimistic mutation results', () => {
done();
break;
default:
done(new Error('Next should not have been called again.'));
done.fail(new Error('Next should not have been called again.'));
}
},
error: error => done(error),
error: error => done.fail(error),
});

function twoMutations() {
Expand All @@ -1188,15 +1188,15 @@ describe('optimistic mutation results', () => {
optimisticResponse: customOptimisticResponse1,
updateQueries,
})
.catch(error => done(error));
.catch(error => done.fail(error));

client
.mutate({
mutation,
optimisticResponse: customOptimisticResponse2,
updateQueries,
})
.catch(error => done(error));
.catch(error => done.fail(error));
}
});
});
Expand Down Expand Up @@ -1681,10 +1681,10 @@ describe('optimistic mutation results', () => {
done();
break;
default:
done(new Error('Next should not have been called again.'));
done.fail(new Error('Next should not have been called again.'));
}
},
error: error => done(error),
error: error => done.fail(error),
});

function twoMutations() {
Expand All @@ -1694,15 +1694,15 @@ describe('optimistic mutation results', () => {
optimisticResponse: customOptimisticResponse1,
update,
})
.catch(error => done(error));
.catch(error => done.fail(error));

client
.mutate({
mutation,
optimisticResponse: customOptimisticResponse2,
update,
})
.catch(error => done(error));
.catch(error => done.fail(error));
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo-client/src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,10 +951,10 @@ export class QueryManager<TStore> {
this.queries.forEach((info, id) => {
if (!info.invalidated || !info.listeners) return;
info.listeners
// it's possible for the listener to be undefined if the query is being stopped
// See here for more detail: https://github.com/apollostack/apollo-client/issues/231
.filter((x: QueryListener) => !!x)
.forEach((listener: QueryListener) => {
// it's possible for the listener to be undefined if the query is being stopped
// See here for more detail: https://github.com/apollostack/apollo-client/issues/231
listener(this.queryStore.get(id), info.newData);
});
});
Expand Down
Loading