diff options
Diffstat (limited to '__tests__/lib/errors.test.ts')
-rw-r--r-- | __tests__/lib/errors.test.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/__tests__/lib/errors.test.ts b/__tests__/lib/errors.test.ts new file mode 100644 index 000000000..b9549e6d8 --- /dev/null +++ b/__tests__/lib/errors.test.ts @@ -0,0 +1,19 @@ +import {isNetworkError} from '../../src/lib/errors' + +describe('isNetworkError', () => { + const inputs = [ + 'TypeError: Network request failed', + 'Uncaught TypeError: Cannot read property x of undefined', + 'Uncaught RangeError', + 'Error: Aborted', + ] + const outputs = [true, false, false, true] + + it('correctly distinguishes network errors', () => { + for (let i = 0; i < inputs.length; i++) { + const input = inputs[i] + const result = isNetworkError(input) + expect(result).toEqual(outputs[i]) + } + }) +}) |