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

Write unit tests for W2JobInfo #654

Closed
thegrims opened this issue Oct 19, 2021 · 7 comments · Fixed by #663 or #675
Closed

Write unit tests for W2JobInfo #654

thegrims opened this issue Oct 19, 2021 · 7 comments · Fixed by #663 or #675
Labels

Comments

@thegrims
Copy link
Collaborator

Acceptance Criteria:

  • jest unit tests for src/components/income/W2JobInfo.tsx
  • coverage above 80%
@arisaokasaka
Copy link
Contributor

@thegrims
Hello, can I work on this issue?

@thegrims
Copy link
Collaborator Author

@arisaokasaka yeah absolutely

@zakpatterson
Copy link
Collaborator

Reopening, the tests merged in #663 are now causing some failures:

 FAIL  src/tests/components/income/W2JobInfo.test.tsx (15.624 s)
  ● W2JobInfo › shows spouse W2 message

    TestingLibraryElementError: Unable to find an element with the text: /Filing status is set to Married Filing Separately./. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

      192 |
      193 |     expect(
    > 194 |       screen.getByText(/Filing status is set to Married Filing Separately./)
          |              ^
      195 |     )
      196 |   })
      197 |

      at Object.getElementError (node_modules/@testing-library/dom/dist/config.js:38:19)
      at node_modules/@testing-library/dom/dist/query-helpers.js:90:38
      at node_modules/@testing-library/dom/dist/query-helpers.js:62:17
      at getByText (node_modules/@testing-library/dom/dist/query-helpers.js:111:19)
      at Object.<anonymous> (src/tests/components/income/W2JobInfo.test.tsx:194:14)

  ● W2JobInfo › saves information

    Unable to find an element with the text: test employer. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

                    

      217 |     clickButton('Save')
      218 |
    > 219 |     await waitFor(() => {
          |           ^
      220 |       expect(screen.getByText('test employer')).toBeInTheDocument()
      221 |       expect(screen.getByText('$2,222')).toBeInTheDocument()
      222 |     })

      at waitForWrapper (node_modules/@testing-library/dom/dist/wait-for.js:182:27)
      at Object.<anonymous> (src/tests/components/income/W2JobInfo.test.tsx:219:11)

  ● W2JobInfo › removes item of list

    TestingLibraryElementError: Unable to find an element with the text: w2s employer name. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

      228 |
      229 |       expect(
    > 230 |         screen.getByText(testW2sSpouse.employer.employerName)
          |                ^
      231 |       ).toBeInTheDocument()
      232 |
      233 |       userEvent.click(screen.getAllByRole('button')[1])

      at Object.getElementError (node_modules/@testing-library/dom/dist/config.js:38:19)
      at node_modules/@testing-library/dom/dist/query-helpers.js:90:38
      at node_modules/@testing-library/dom/dist/query-helpers.js:62:17
      at getByText (node_modules/@testing-library/dom/dist/query-helpers.js:111:19)
      at Object.<anonymous> (src/tests/components/income/W2JobInfo.test.tsx:230:16)

  ● W2JobInfo › sets current information when editing

    expect(element).toHaveValue(w2s employer name)

    Expected the element to have value:
      w2s employer name
    Received:

      244 |     userEvent.click(screen.getAllByRole('button')[0])
      245 |
    > 246 |     expect(screen.getByLabelText('Employer name')).toHaveValue(
          |                                                    ^
      247 |       testW2sSpouse.employer?.employerName
      248 |     )
      249 |     expect(

      at Object.<anonymous> (src/tests/components/income/W2JobInfo.test.tsx:246:52)

  ● W2JobInfo › updates information

    Unable to find an element with the text: updated employer name. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.


      304 |     clickButton('Save')
      305 |
    > 306 |     await waitFor(() => {
          |           ^
      307 |       expect(screen.getByText('updated employer name')).toBeInTheDocument()
      308 |       expect(screen.getByText('$8,888')).toBeInTheDocument()
      309 |     })

      at waitForWrapper (node_modules/@testing-library/dom/dist/wait-for.js:182:27)
      at Object.<anonymous> (src/tests/components/income/W2JobInfo.test.tsx:306:11)


@zakpatterson zakpatterson reopened this Oct 21, 2021
@zakpatterson
Copy link
Collaborator

@arisaokasaka let us know if you can take another look? The above are from running on master right now.

@arisaokasaka
Copy link
Contributor

Sorry! I will check this weekend.

@thegrims
Copy link
Collaborator Author

@arisaokasaka no worries!

@arisaokasaka
Copy link
Contributor

@thegrims
I think I've found the cause of the problem, so I've addressed it!
I hope you'll check it out when you have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants