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

Trouble Tests to Revisit #64

Open
hfaerber opened this issue Jan 6, 2020 · 2 comments
Open

Trouble Tests to Revisit #64

hfaerber opened this issue Jan 6, 2020 · 2 comments
Labels
unit-test-fundamentals Unit Testing for UI Snapshots, changes in state, and event simulation

Comments

@hfaerber
Copy link
Collaborator

hfaerber commented Jan 6, 2020

Navigation Bar - STILL FAILING

  1. FAILING TEST because home-button can't be found bc it is wrapped in
it('should invoke handleError props with empty string when button is clicked',
      () => {
        console.log(wrapper.debug())
        wrapper.find('.home-button').simulate('click');
        expect(mockHandleError).toHaveBeenCalledWith('');
    });

Component:

return (
    <header className='header'>
      <Link to='/'>
        <Route
          path={['/login', '/movies/:id']}
          render={() =>
            <button
              className='home-button'
              onClick={() => {
                handleError('')
              }}>
              Home
            </button>}
        />
      </Link>

Login Form - PASSING!

PASSING! 1) Testing invocation of a dispatch prop after fetch resolution (within .then() block)
Error - FAILING - NUMBER OF CALLS: 0

it('should invoke updateLoggedInStatus with true when fetchRatings has resolved', () => {
      fetchRatings(9);
      expect(mockUpdateLoggedInStatus).toHaveBeenCalled();
    });

PASSING! 2) Testing invocation of a dispatch prop after fetch resolution (within .then() block)
Error - FAILING - NUMBER OF CALLS: 0

it('should invoke updateUser with data passed in when fetchRatings has resolved', async () => {
      await fetchRatings(9);
      expect(mockupdateUser).toHaveBeenCalled();
    });

PASSING! 3) HOW WILL WE TEST WHETHER HANDLEERROR IS INVOKED IN .CATCH() FOR FETCH?

MovieShowPage - PASSING!

  1. Testing invocation of a dispatch prop after fetch resolution (within .then() block)
    Error - FAILING - NUMBER OF CALLS: 0
it('should invoke updateUser when fetchRatings resolves', () => {
    let mockNewRatings = {id: 9, name: 'Marge', email: '[email protected]',
        ratings: [
      {id: 45, user_id: 9, movie_id: 8, rating: 8,
        created_at: "2019-12-25T20:16:34.893Z",
        updated_at: "2019-12-25T20:16:34.893Z"
      },
      {id: 46, user_id: 9, movie_id: 10, rating: 5,
        created_at: "2019-12-25T20:30:21.606Z",
        updated_at: "2019-12-25T20:30:21.606Z"
      } ]};
    fetchRatings(9);
    expect(mockUpdateUser).toHaveBeenCalledWith(mockNewRatings);
  });

DeleteRating Async- PASSING!

  • How can we test the Happy path considering nothing is returned?
@hfaerber hfaerber added the unit-test-fundamentals Unit Testing for UI Snapshots, changes in state, and event simulation label Jan 6, 2020
@hfaerber
Copy link
Collaborator Author

hfaerber commented Jan 6, 2020

@ericweissman
These are examples of testing situations that we have not found solutions for.

@hfaerber hfaerber mentioned this issue Jan 7, 2020
Merged
@hfaerber
Copy link
Collaborator Author

hfaerber commented Jan 7, 2020

All tests are now passing except the Navigation Bar test that has the button wrapped in the route. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unit-test-fundamentals Unit Testing for UI Snapshots, changes in state, and event simulation
Projects
None yet
Development

No branches or pull requests

1 participant