mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 23:46:28 +00:00
20 lines
976 B
JavaScript
20 lines
976 B
JavaScript
const { logCorrelation, logStatusCode, logErrorCode } = require('../helpers/log-fields');
|
|
|
|
test('membatasi korelasi ke format yang dipakai aplikasi', () => {
|
|
expect(logCorrelation(123456789)).toBe('123456789');
|
|
expect(logCorrelation('9af6e483-10b9-414d-9eb9-f113de42532b'))
|
|
.toBe('9af6e483-10b9-414d-9eb9-f113de42532b');
|
|
expect(logCorrelation('fixture\nextra')).toBe('unknown');
|
|
expect(logCorrelation({ number: '123' })).toBe('unknown');
|
|
});
|
|
|
|
test('mempertahankan kode berguna tanpa isi pesan error', () => {
|
|
expect(logStatusCode('00')).toBe('00');
|
|
expect(logStatusCode(404)).toBe('404');
|
|
expect(logStatusCode('404 fixture-detail')).toBe('UNKNOWN');
|
|
expect(logErrorCode({ code: '23514', message: 'fixture SQL parameters' })).toBe('23514');
|
|
expect(logErrorCode({ code: 'ETIMEDOUT' })).toBe('ETIMEDOUT');
|
|
expect(logErrorCode({ code: 'fixture-private', name: 'TypeError' })).toBe('TypeError');
|
|
expect(logErrorCode('fixture message')).toBe('Error');
|
|
});
|