Skip to content

Difficulties testing updateCache helper #1442

Answered by flacial
flacial asked this question in Q&A
Discussion options

You must be logged in to vote

I found a solution. It'll basically do:

  1. Write the query
  2. Update the cache
  3. Read the query and check if the comments are empty or not
  it('should delete previous submission comment in cache', () => {
    expect.assertions(1)

    const cache = new InMemoryCache({ addTypename: false })

    cache.writeQuery({
      query: GET_PREVIOUS_SUBMISSIONS,
      variables: { userId: 1, challengeId: 23 },
      data: { getPreviousSubmissions: submissionsData }
    })

    updateCache(
      0,
      1,
      'Test comment!',
      'Test User',
      'testuser',
      2,
      undefined,
      undefined,
      23,
      1
    )(cache)

    const newCache = cache.readQuery({
      query: GET_PREVIOUS_…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@anthonykhoa
Comment options

Comment options

flacial
Feb 10, 2022
Maintainer Author

You must be logged in to vote
1 reply
@JasirZaeem
Comment options

Answer selected by flacial
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants