char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
92d1bb0c9
char/aliceai-t5-moe
1import { isAbortError } from '$lib/utils/abort' ; 2import { describe , expect , it } from 'vitest' ; 3 4describe ( 'isAbortError' , () => { 5it ( 'returns false for null, undefined and non-error values' , () => { 6expect ( isAbortError ( null )). toBe ( false ); 7expect ( isAbortError ( undefined )). toBe ( false ); 8expect ( isAbortError ( 'string error' )). toBe ( false ); 9expect ( isAbortError ({ name :'AbortError' })). toBe ( false ); 10expect ( isAbortError ( 42 )). toBe ( false ); 11}); 12 13it ( 'returns true for DOMException with AbortError name' , () => { 14const err = new DOMException ( 'Operation was aborted' , 'AbortError' ); 15 16expect ( isAbortError ( err )). toBe ( true ); 17}); 18 19it ( 'returns true for plain Error with AbortError name' , () => { 20const err = new Error ( 'aborted' ); 21 22err . name = 'AbortError' ; 23expect ( isAbortError ( err )). toBe ( true ); 24}); 25 26it ( 'returns false for unrelated Error instances' , () => { 27expect ( isAbortError ( new Error ( 'something failed' ))). toBe ( false ); 28expect ( isAbortError ( new TypeError ( 'not related' ))). toBe ( false ); 29expect ( isAbortError ( new RangeError ( 'out of range' ))). toBe ( false ); 30}); 31 32it ( 'recognizes Firefox TypeError "Error in input stream" emitted at page unload' , () => { 33expect ( isAbortError ( new TypeError ( 'Error in input stream' ))). toBe ( true ); 34expect ( isAbortError ( new TypeError ( 'TypeError: Error in input stream' ))). toBe ( true ); 35}); 36 37it ( 'recognizes Safari "The network connection was lost" during transient drop' , () => { 38expect ( isAbortError ( new TypeError ( 'The network connection was lost.' ))). toBe ( true ); 39}); 40 41it ( 'recognizes Safari "Load failed" during page navigation' , () => { 42expect ( isAbortError ( new TypeError ( 'Load failed' ))). toBe ( true ); 43}); 44 45it ( 'does NOT recognize generic TypeError messages as aborts' , () => { 46// matching too broadly would hide real bugs, the predicate must stay conservative 47expect ( isAbortError ( new TypeError ( 'Failed to fetch' ))). toBe ( false ); 48expect ( isAbortError ( new TypeError ( 'Cannot read property of undefined' ))). toBe ( false ); 49expect ( isAbortError ( new TypeError ( 'NetworkError when attempting to fetch resource' ))). toBe ( 50false 51); 52}); 53 54it ( 'is case insensitive on the matched substrings' , () => { 55expect ( isAbortError ( new TypeError ( 'error in INPUT STREAM' ))). toBe ( true ); 56expect ( isAbortError ( new TypeError ( 'the network connection WAS LOST' ))). toBe ( true ); 57}); 58});