Skip to content

Commit

Permalink
fix some namings
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikzogg committed Apr 13, 2020
1 parent bcde234 commit fcab94c
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/Component/Partial/HttpError.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import HttpErrorType from '../../Model/Error/HttpError';
import HttpErrorWithInvalidArguments from '../../Model/Error/HttpErrorWithInvalidArguments';
import HttpErrorWithInvalidParameters from '../../Model/Error/HttpErrorWithInvalidParameters';
import InvalidParameter from '../../Model/Error/InvalidParameter';

type Props = {
Expand All @@ -13,7 +13,7 @@ const HttpError: React.FC<Props> = ({ httpError }: Props) => {
<p>{httpError.title}</p>
{httpError.detail ? (<p>{httpError.detail}</p>) : ''}
{httpError.instance ? (<p>{httpError.instance}</p>) : ''}
{httpError instanceof HttpErrorWithInvalidArguments && httpError.invalidParameters.length > 0 ? (
{httpError instanceof HttpErrorWithInvalidParameters && httpError.invalidParameters.length > 0 ? (
<ul>
{httpError.invalidParameters.map((invalidParameter: InvalidParameter, i) => (
<li key={i}><strong>{invalidParameter.name}</strong>: {invalidParameter.reason}</li>
Expand Down
2 changes: 1 addition & 1 deletion src/Denormalizer/InvalidParameterByNameDenormalizer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import InvalidParameter from '../Model/Error/InvalidParameter';

type errorsByFieldsType = { [id: string]: Array<InvalidParameter> };
type errorsByFieldsType = { [id: string]: Array<InvalidParameter>; };

const InvalidParameterByNameDenormalizer = (invalidParameters: Array<InvalidParameter>): errorsByFieldsType => {
const errorsByFields: errorsByFieldsType = {};
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Error/BadRequest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import HttpErrorWithInvalidArguments from './HttpErrorWithInvalidArguments';
import HttpErrorWithInvalidParameters from './HttpErrorWithInvalidParameters';

class BadRequest extends HttpErrorWithInvalidArguments {
class BadRequest extends HttpErrorWithInvalidParameters {
};

export default BadRequest;
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import HttpError from './HttpError';
import InvalidParameter from './InvalidParameter';

class HttpErrorWithInvalidArguments extends HttpError {
class HttpErrorWithInvalidParameters extends HttpError {
invalidParameters: Array<InvalidParameter>;
constructor({ title, detail, instance, invalidParameters }: { title: string, detail?: string, instance?: string, invalidParameters?: Array<InvalidParameter>; }) {
super({ title, detail, instance });
this.invalidParameters = invalidParameters ?? [];
}
};

export default HttpErrorWithInvalidArguments;
export default HttpErrorWithInvalidParameters;
4 changes: 2 additions & 2 deletions src/Model/Error/UnprocessableEntity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import HttpErrorWithInvalidArguments from './HttpErrorWithInvalidArguments';
import HttpErrorWithInvalidParameters from './HttpErrorWithInvalidParameters';

class UnprocessableEntity extends HttpErrorWithInvalidArguments {
class UnprocessableEntity extends HttpErrorWithInvalidParameters {
};

export default UnprocessableEntity;
8 changes: 4 additions & 4 deletions src/__tests__/Component/Form/PetFilterForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PetFilterForm from '../../../Component/Form/PetFilterForm';
import PetFilters from '../../../Model/Pet/PetFilters';

test('without error', () => {
const submitPetFilter: { (filters: any): any; } = (filters: any) => { };
const submitPetFilter = (filters: PetFilters) => { };

const filters = new PetFilters({name: 'aa'});

Expand All @@ -30,7 +30,7 @@ test('without error', () => {
});

test('with error', () => {
const submitPetFilter: { (filters: any): any; } = (filters: any) => { };
const submitPetFilter = (filters: PetFilters) => { };

const filters = new PetFilters({name: ''});

Expand Down Expand Up @@ -66,7 +66,7 @@ test('with error', () => {
});

test('submit', async () => {
const submitPetFilter: { (filters: any): any; } = jest.fn((filters: any) => { });
const submitPetFilter = jest.fn((filters: any) => { });

const filters = new PetFilters({name: 'aa'});

Expand Down Expand Up @@ -98,7 +98,7 @@ test('submit', async () => {
});

test('submit empty', async () => {
const submitPetFilter: { (filters: any): any; } = jest.fn((filters: any) => { });
const submitPetFilter = jest.fn((filters: any) => { });

const filters = new PetFilters({name: ''});

Expand Down
13 changes: 7 additions & 6 deletions src/__tests__/Component/Partial/HttpError.test.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React from 'react';
import { render } from '@testing-library/react';
import HttpErrorWithInvalidArguments from '../../../Model/Error/HttpErrorWithInvalidArguments';
import HttpError from '../../../Component/Partial/HttpError';
import HttpError from '../../../Model/Error/HttpError';
import HttpErrorPartial from '../../../Component/Partial/HttpError';
import HttpErrorWithInvalidParameters from '../../../Model/Error/HttpErrorWithInvalidParameters';

test('minimal', () => {
const httpError = new HttpErrorWithInvalidArguments({
const httpError = new HttpError({
title: 'This is the title'
});

const { container } = render(<HttpError httpError={httpError} />);
const { container } = render(<HttpErrorPartial httpError={httpError} />);

expect(container.outerHTML).toBe(`
<div>
Expand All @@ -20,7 +21,7 @@ test('minimal', () => {
});

test('maximal', () => {
const httpError = new HttpErrorWithInvalidArguments({
const httpError = new HttpErrorWithInvalidParameters({
title: 'This is the title',
detail: 'This is the detail',
instance: 'This is the instance',
Expand All @@ -29,7 +30,7 @@ test('maximal', () => {
]
});

const { container } = render(<HttpError httpError={httpError} />);
const { container } = render(<HttpErrorPartial httpError={httpError} />);

expect(container.outerHTML).toBe(`
<div>
Expand Down
16 changes: 8 additions & 8 deletions src/__tests__/Component/Partial/Pagination.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { render } from '@testing-library/react';
import Pagination from '../../../Component/Partial/Pagination';

test('max pages 1', () => {
const submitPage = (page: number) => {
const submitPage = (page: number): void => {

};

Expand All @@ -17,7 +17,7 @@ test('max pages 1', () => {
});

test('total pages 1', () => {
const submitPage = (page: number) => {
const submitPage = (page: number): void => {

};

Expand All @@ -31,7 +31,7 @@ test('total pages 1', () => {
});

test('current 1', () => {
const submitPage = (page: number) => {
const submitPage = (page: number): void => {

};

Expand All @@ -55,7 +55,7 @@ test('current 1', () => {
});

test('current 4', () => {
const submitPage = (page: number) => {
const submitPage = (page: number): void => {

};

Expand All @@ -81,7 +81,7 @@ test('current 4', () => {
});

test('current 7', () => {
const submitPage = (page: number) => {
const submitPage = (page: number): void => {

};

Expand All @@ -107,7 +107,7 @@ test('current 7', () => {
});

test('current 10', () => {
const submitPage = (page: number) => {
const submitPage = (page: number): void => {

};

Expand All @@ -133,13 +133,13 @@ test('current 10', () => {
test('buttons', async () => {
const pages: number[] = [];

const submitPage = (page: number) => {
const submitPage = (page: number): void => {
pages.push(page);
};

const { container } = render(<Pagination currentPage={7} maxPages={7} totalPages={10} submitPage={submitPage} />);

for (let element of container.getElementsByTagName('button')) {
for (const element of container.getElementsByTagName('button')) {
element.click();
}

Expand Down

0 comments on commit fcab94c

Please sign in to comment.