Skip to content

Commit

Permalink
Regression test for PRs #6898 and #6817.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Aug 25, 2020
1 parent 889d103 commit 53455f5
Showing 1 changed file with 106 additions and 0 deletions.
106 changes: 106 additions & 0 deletions src/core/__tests__/QueryManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,112 @@ describe('QueryManager', () => {
});
});

itAsync("should disable feud-stopping logic after evict or modify", (resolve, reject) => {
const cache = new InMemoryCache({
typePolicies: {
Query: {
fields: {
info: {
merge: false,
},
},
},
},
});

const client = new ApolloClient({
cache,
link: new ApolloLink(operation => new Observable((observer: Observer<FetchResult>) => {
observer.next!({ data: { info: { c: "see" }}});
observer.complete!();
})),
});

const query = gql`query { info { c } }`;

const obs = client.watchQuery({
query,
returnPartialData: true,
});

subscribeAndCount(reject, obs, (count, result) => {
if (count === 1) {
expect(result).toEqual({
loading: true,
networkStatus: NetworkStatus.loading,
data: {},
partial: true,
});

} else if (count === 2) {
expect(result).toEqual({
loading: false,
networkStatus: NetworkStatus.ready,
data: {
info: {
c: "see",
},
},
});

cache.evict({
fieldName: "info",
});

} else if (count === 3) {
expect(result).toEqual({
loading: true,
networkStatus: NetworkStatus.loading,
data: {},
partial: true,
});

} else if (count === 4) {
expect(result).toEqual({
loading: false,
networkStatus: NetworkStatus.ready,
data: {
info: {
c: "see",
},
},
});

cache.modify({
fields: {
info(_, { DELETE }) {
return DELETE;
},
},
});

} else if (count === 5) {
expect(result).toEqual({
loading: true,
networkStatus: NetworkStatus.loading,
data: {},
partial: true,
});

} else if (count === 6) {
expect(result).toEqual({
loading: false,
networkStatus: NetworkStatus.ready,
data: {
info: {
c: "see",
},
},
});

setTimeout(resolve, 100);

} else {
reject(new Error(`Unexpected ${JSON.stringify({count,result})}`));
}
});
});

itAsync('should not error when replacing unidentified data with a normalized ID', (resolve, reject) => {
const queryWithoutId = gql`
query {
Expand Down

0 comments on commit 53455f5

Please sign in to comment.