mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-23 10:18:40 +00:00
Co-authored-by: Mikael Finstad <finstaden@gmail.com> Co-authored-by: Nick Rutten <2504906+nickrttn@users.noreply.github.com> Co-authored-by: Murderlon <merlijn@soverin.net> Co-authored-by: Artur Paikin <artur@arturpaikin.com>
35 lines
1,014 B
TypeScript
35 lines
1,014 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import isNetworkError from './isNetworkError.ts'
|
|
|
|
describe('isNetworkError', () => {
|
|
it('should return true if the specified xhr object contains a network error', () => {
|
|
const xhrNetworkErrorMock = {
|
|
readyState: 4,
|
|
responseText: '',
|
|
status: 0,
|
|
} as any as XMLHttpRequest
|
|
|
|
const xhrNetworkError2Mock = {
|
|
readyState: 2,
|
|
responseText: '',
|
|
status: 300,
|
|
} as any as XMLHttpRequest
|
|
|
|
const xhrRegularErrorMock = {
|
|
readyState: 4,
|
|
responseText: 'Failed',
|
|
status: 400,
|
|
} as any as XMLHttpRequest
|
|
|
|
const xhrNetworkSuccessMock = {
|
|
readyState: 4,
|
|
responseText: 'Success',
|
|
status: 200,
|
|
} as any as XMLHttpRequest
|
|
|
|
expect(isNetworkError(xhrNetworkErrorMock)).toEqual(true)
|
|
expect(isNetworkError(xhrNetworkError2Mock)).toEqual(true)
|
|
expect(isNetworkError(xhrRegularErrorMock)).toEqual(false)
|
|
expect(isNetworkError(xhrNetworkSuccessMock)).toEqual(false)
|
|
})
|
|
})
|