⚝
One Hat Cyber Team
⚝
Your IP:
216.73.217.4
Server IP:
41.128.143.86
Server:
Linux host.raqmix.cloud 6.8.0-1025-azure #30~22.04.1-Ubuntu SMP Wed Mar 12 15:28:20 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.3.23
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
grafana
/
public
/
app
/
core
/
utils
/
Edit File: errors.test.ts
import { FetchError } from '@grafana/runtime'; import { getMessageFromError } from 'app/core/utils/errors'; describe('errors functions', () => { let message: string | null; describe('when getMessageFromError gets an error string', () => { beforeEach(() => { message = getMessageFromError('error string'); }); it('should return the string', () => { expect(message).toBe('error string'); }); }); describe('when getMessageFromError gets an error object with message field', () => { beforeEach(() => { message = getMessageFromError(new Error('error string')); }); it('should return the message text', () => { expect(message).toBe('error string'); }); }); describe('when getMessageFromError gets an error object with data.message field', () => { beforeEach(() => { message = getMessageFromError({ data: { message: 'error string' }, status: 500 } as FetchError); }); it('should return the message text', () => { expect(message).toBe('error string'); }); }); describe('when getMessageFromError gets an error object with statusText field', () => { beforeEach(() => { message = getMessageFromError({ data: 'foo', statusText: 'error string', status: 500 } as FetchError); }); it('should return the statusText text', () => { expect(message).toBe('error string'); }); }); describe('when getMessageFromError gets an error object', () => { beforeEach(() => { message = getMessageFromError({ customError: 'error string' }); }); it('should return the stringified error', () => { expect(message).toBe('{"customError":"error string"}'); }); }); });
Simpan