Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(repro): test case repro #3500

Merged
merged 7 commits into from
May 29, 2018
Merged
Changes from 1 commit
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
Next Next commit
fix(repro): test case repro
  • Loading branch information
abhiaiyer91 committed May 22, 2018
commit e40bee93cb24a99f2f99afa239c3dc29d329a109
38 changes: 38 additions & 0 deletions packages/apollo-client/src/__tests__/fetchMore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,44 @@ describe('fetchMore on an observable query', () => {
sub = null;
}

it('triggers new result with new variables', () => {
latestResult = null;
return setup({
request: {
query,
variables: variablesMore,
},
result: resultMore,
})
.then(watchedQuery => {
return watchedQuery.fetchMore({
variables: { start: 10 }, // rely on the fact that the original variables had limit: 10
updateQuery: (prev, options) => {
console.log(prev, options, 'YOOOOO MY TEST DOE');

expect(options.variables).toEqual(variablesMore);

const state = cloneDeep(prev) as any;
state.entry.comments = [
...state.entry.comments,
...(options.fetchMoreResult as any).entry.comments,
];
return state;
},
});
})
.then(data => {
expect(data.data.entry.comments).toHaveLength(10); // this is the server result
expect(data.loading).toBe(false);
const comments = latestResult.data.entry.comments;
expect(comments).toHaveLength(20);
for (let i = 1; i <= 20; i++) {
expect(comments[i - 1].text).toEqual(`comment ${i}`);
}
unsetup();
});
});

it('basic fetchMore results merging', () => {
latestResult = null;
return setup({
Expand Down