axios-hooks
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -5,2 +5,6 @@ # Changelog | ||
### [1.1.3](https://github.com/simoneb/axios-hooks/compare/v1.1.2...v1.1.3) (2019-07-12) | ||
### [1.1.2](https://github.com/simoneb/axios-hooks/compare/v1.1.1...v1.1.2) (2019-06-30) | ||
@@ -7,0 +11,0 @@ |
@@ -113,3 +113,4 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
return _extends({}, state, { | ||
loading: true | ||
loading: true, | ||
error: null | ||
}); | ||
@@ -116,0 +117,0 @@ |
@@ -132,3 +132,4 @@ "use strict"; | ||
return (0, _extends3["default"])({}, state, { | ||
loading: true | ||
loading: true, | ||
error: null | ||
}); | ||
@@ -135,0 +136,0 @@ |
{ | ||
"name": "axios-hooks", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "axios-hooks", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -69,3 +69,4 @@ import React from 'react' | ||
...state, | ||
loading: true | ||
loading: true, | ||
error: null | ||
} | ||
@@ -72,0 +73,0 @@ case actions.REQUEST_END: |
@@ -12,3 +12,3 @@ import { renderHook, act } from 'react-hooks-testing-library' | ||
test('should set loading to false when request completes and return data', async () => { | ||
test('should set loading to false when request completes and returns data', async () => { | ||
const { result, waitForNextUpdate } = renderHook(() => useAxios()) | ||
@@ -26,4 +26,22 @@ | ||
test('should set loading to false when request completes and return error', async () => { | ||
test('should reset error when request completes and returns data', async () => { | ||
const { result, waitForNextUpdate } = renderHook(() => useAxios()) | ||
result.current[0].error = new Error() | ||
act(() => { | ||
axios.resolvePromise({ data: 'whatever' }) | ||
}) | ||
await waitForNextUpdate() | ||
// Refetch | ||
act(() => { | ||
result.current[1]() | ||
}) | ||
expect(result.current[0].error).toBe(null) | ||
}) | ||
test('should set loading to false when request completes and returns error', async () => { | ||
const { result, waitForNextUpdate } = renderHook(() => useAxios()) | ||
const error = new Error('boom') | ||
@@ -30,0 +48,0 @@ |
29230
563