Skip to content

Commit

Permalink
test: SDKError.ts
Browse files Browse the repository at this point in the history
JIRA: UUI-767
  • Loading branch information
michal-oleniacz-stp committed Feb 26, 2024
1 parent fa775aa commit bb5b223
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions __tests__/SDKError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@
* See LICENSE.md in the project root.
*/

// @ts-nocheck

'use strict';

import SDKError from '../src/utils/SDKError';

const ERROR = new Error('TEST ERROR');

describe('SDKError', () => {

const EXPECTED_ERROR_MSG = /SDKError: foo/;

test('Should be able to stringify an error', () => {
const e = new SDKError('foo', { bar: 'baz' });
const expectedMessage = 'foo';
const e = new SDKError(expectedMessage, ERROR);

// FIXME: Enable this when.. we have babel7 and it (hopefully) works with Jest+Coverage
// expect(e.toString()).toBe('SDKError: foo\n bar: baz');
expect(e.toString()).toMatch(/SDKError: foo/);
});

test('Should be able to stringify an error with params by explicit function invocation', () => {
const e = new SDKError('foo', { bar: 'baz' });
expect(SDKError.prototype.toString.call(e)).toMatch(/SDKError: foo\n {4}bar: baz/);
const expectedMessage = 'foo';
const e = new SDKError(expectedMessage, ERROR);

expect(SDKError.prototype.toString.call(e)).toMatch(EXPECTED_ERROR_MSG);
});

test('Should be able to stringify an error by explicit function invocation', () => {
const e = new SDKError('foo');
expect(SDKError.prototype.toString.call(e)).toMatch(/SDKError: foo/);
expect(SDKError.prototype.toString.call(e)).toMatch(EXPECTED_ERROR_MSG);
});
});

0 comments on commit bb5b223

Please sign in to comment.