mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 04:06:39 +00:00
Added support for API v3 error types on different error handlers
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { ShlinkApiError, ShlinkApiErrorProps } from '../../src/api/ShlinkApiError';
|
||||
import { InvalidArgumentError, ProblemDetailsError } from '../../src/api/types';
|
||||
import { ErrorTypeV2, ErrorTypeV3, InvalidArgumentError, ProblemDetailsError } from '../../src/api/types/errors';
|
||||
|
||||
describe('<ShlinkApiError />', () => {
|
||||
const setUp = (props: ShlinkApiErrorProps) => render(<ShlinkApiError {...props} />);
|
||||
@@ -20,7 +20,8 @@ describe('<ShlinkApiError />', () => {
|
||||
it.each([
|
||||
[undefined, 0],
|
||||
[Mock.all<ProblemDetailsError>(), 0],
|
||||
[Mock.of<InvalidArgumentError>({ type: 'INVALID_ARGUMENT', invalidElements: [] }), 1],
|
||||
[Mock.of<InvalidArgumentError>({ type: ErrorTypeV2.INVALID_ARGUMENT, invalidElements: [] }), 1],
|
||||
[Mock.of<InvalidArgumentError>({ type: ErrorTypeV3.INVALID_ARGUMENT, invalidElements: [] }), 1],
|
||||
])('renders list of invalid elements when provided error is an InvalidError', (errorData, expectedElementsCount) => {
|
||||
setUp({ errorData });
|
||||
expect(screen.queryAllByText(/^Invalid elements/)).toHaveLength(expectedElementsCount);
|
||||
|
||||
@@ -2,9 +2,10 @@ import { screen, waitFor } from '@testing-library/react';
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { DomainsList } from '../../src/domains/reducers/domainsList';
|
||||
import { ManageDomains } from '../../src/domains/ManageDomains';
|
||||
import { ProblemDetailsError, ShlinkDomain } from '../../src/api/types';
|
||||
import { ShlinkDomain } from '../../src/api/types';
|
||||
import { SelectedServer } from '../../src/servers/data';
|
||||
import { renderWithEvents } from '../__helpers__/setUpTest';
|
||||
import { ProblemDetailsError } from '../../src/api/types/errors';
|
||||
|
||||
describe('<ManageDomains />', () => {
|
||||
const listDomains = jest.fn();
|
||||
|
||||
@@ -3,8 +3,8 @@ import { Mock } from 'ts-mockery';
|
||||
import { DeleteShortUrlModal } from '../../../src/short-urls/helpers/DeleteShortUrlModal';
|
||||
import { ShortUrl } from '../../../src/short-urls/data';
|
||||
import { ShortUrlDeletion } from '../../../src/short-urls/reducers/shortUrlDeletion';
|
||||
import { ProblemDetailsError } from '../../../src/api/types';
|
||||
import { renderWithEvents } from '../../__helpers__/setUpTest';
|
||||
import { ProblemDetailsError } from '../../../src/api/types/errors';
|
||||
|
||||
describe('<DeleteShortUrlModal />', () => {
|
||||
const shortUrl = Mock.of<ShortUrl>({
|
||||
|
||||
@@ -7,8 +7,8 @@ import reducer, {
|
||||
resetDeleteShortUrl,
|
||||
deleteShortUrl,
|
||||
} from '../../../src/short-urls/reducers/shortUrlDeletion';
|
||||
import { ProblemDetailsError } from '../../../src/api/types';
|
||||
import { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||
import { ProblemDetailsError } from '../../../src/api/types/errors';
|
||||
|
||||
describe('shortUrlDeletionReducer', () => {
|
||||
describe('reducer', () => {
|
||||
|
||||
@@ -3,8 +3,8 @@ import { Mock } from 'ts-mockery';
|
||||
import { TagEdition } from '../../../src/tags/reducers/tagEdit';
|
||||
import { EditTagModal as createEditTagModal } from '../../../src/tags/helpers/EditTagModal';
|
||||
import { ColorGenerator } from '../../../src/utils/services/ColorGenerator';
|
||||
import { ProblemDetailsError } from '../../../src/api/types';
|
||||
import { renderWithEvents } from '../../__helpers__/setUpTest';
|
||||
import { ProblemDetailsError } from '../../../src/api/types/errors';
|
||||
|
||||
describe('<EditTagModal />', () => {
|
||||
const EditTagModal = createEditTagModal(Mock.of<ColorGenerator>({ getColorForKey: jest.fn(() => 'green') }));
|
||||
|
||||
Reference in New Issue
Block a user