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

Add useClientRequest fetchData tests with warnings #32

Merged
merged 4 commits into from
Feb 20, 2019

Conversation

jackdclark
Copy link
Contributor

Implements the tests that were left out of #30
Resolves #31

    fetchData
      ✓ calls request with options & updates the state with the result (10ms)
      ✓ calls request with revised options (2ms)
      ✓ skips the request & returns the cached data if it exists (2ms)
      ✓ skips the cache if skipCache is passed in (2ms)
      ✓ skips the cache if skipCache is there is no cache (2ms)
      ✓ sets the result from the request in the cache (2ms)

The following warning will display in the console for each test until facebook/react#14769 has been resolved. This is because fetchData updates the state & should be wrapped inside an act, however act does not yet support async/await & fetchData is an async function.

  console.error node_modules/react-dom/cjs/react-dom.development.js:506
    Warning: An update to TestHook inside a test was not wrapped in act(...).

    When testing, code that causes React state updates should be wrapped into act(...):

    act(() => {
      /* fire events that update state */
    });
    /* assert on the output */

    This ensures that you're testing the behavior the user would see in the browser. Learn more at https://fb.me/react-wrap-tests-with-act
        in TestHook
        in Wrapper

@jackdclark jackdclark changed the base branch from test-use-client-request to master February 20, 2019 10:50
@jackdclark jackdclark merged commit 2c16894 into master Feb 20, 2019
@jackdclark jackdclark deleted the test-use-client-with-warnings branch February 20, 2019 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test fetchData from useClientRequest
2 participants