Jaime Ramírez
2020-06-11 d4efcf556bee5599b87a18da9420df2143e1c757
Fix lint and tests (#46)

9 files modified
43 ■■■■ changed files
adopt-a-pup/web-app/.eslintrc.json 2 ●●● patch | view | raw | blame | history
adopt-a-pup/web-app/src/App.tsx 2 ●●● patch | view | raw | blame | history
adopt-a-pup/web-app/src/Components/AdoptionForm.test.tsx 2 ●●● patch | view | raw | blame | history
adopt-a-pup/web-app/src/Components/AnimalCreateForm.tsx 11 ●●●● patch | view | raw | blame | history
adopt-a-pup/web-app/src/Components/NotificationRequestForm.tsx 15 ●●●● patch | view | raw | blame | history
adopt-a-pup/web-app/src/Models/AnimalNotificationRequest.ts 2 ●●●●● patch | view | raw | blame | history
adopt-a-pup/web-app/src/Services/AnimalFakeService.ts 2 ●●● patch | view | raw | blame | history
adopt-a-pup/web-app/src/Views/AnimalCreateView.tsx 5 ●●●● patch | view | raw | blame | history
adopt-a-pup/web-app/src/Views/NotificationsView.tsx 2 ●●● patch | view | raw | blame | history
adopt-a-pup/web-app/.eslintrc.json
@@ -27,7 +27,7 @@
    "rules": {
        "max-len": [
            "error",
            100
            120
        ],
        "indent": [
            "error",
adopt-a-pup/web-app/src/App.tsx
@@ -110,7 +110,7 @@
                                shelterService={shelterService}
                                adoptionService={adoptionService}
                            />} />
                        <Route path={"/notifications"} render={(props) =>
                        <Route path={"/notifications"} render={() =>
                            <NotificationsView animalService={animalService}/>
                        }/>
                    </Structure>
adopt-a-pup/web-app/src/Components/AdoptionForm.test.tsx
@@ -82,7 +82,7 @@
        // Wait until all promises all resolved
        await Promise.resolve();
        expect(component.state("showAdoptSucessAlert")).toBe(true);
        expect(component.state("showAdoptSuccessAlert")).toBe(true);
    });
    test("Does not call AdoptionService.create when empty form is submitted", () => {
adopt-a-pup/web-app/src/Components/AnimalCreateForm.tsx
@@ -78,9 +78,10 @@
        try {
            const shelters = await this.props.shelterService.getAll();
            this.setState({shelters});
            // Set default shelter as first option. If we do not do this the form will not know which one is selected by default
            // Set default shelter as first option.
            //If we do not do this the form will not know which one is selected by default
            if (shelters[0].shelterId) {
                this.handleShelterIdChange(shelters[0].shelterId)
                this.handleShelterIdChange(shelters[0].shelterId);
            }
        } catch (error) {
            if (error instanceof RESTConnectionError) {
@@ -243,7 +244,7 @@
    private isFormValid() {
        const {animal} = this.state;
        const fieldIsEmpty = (field: string) => { return animal[field as keyof Animal] === ""; }
        const fieldIsEmpty = (field: string) => { return animal[field as keyof Animal] === ""; };
        const hasEmptyFields = Object
            .keys(animal)
@@ -383,7 +384,7 @@
                                    key={shelter.shelterId}
                                    value={shelter.shelterId}
                                    label={shelter.shelterName}
                                />
                                />;
                            })}
                        </FormSelect>
                    </FormGroup>
@@ -454,7 +455,7 @@
                                key={approximateSize}
                                value={approximateSize}
                                label={approximateSize}
                            />
                            />;
                        })}
                    </FormSelect>
                </FormGroup>
adopt-a-pup/web-app/src/Components/NotificationRequestForm.tsx
@@ -37,7 +37,8 @@
    }
}
export default class NotificationRequestForm extends React.Component<NotificationRequestFormProps, NotificationRequestFormState> {
export default class NotificationRequestForm
    extends React.Component<NotificationRequestFormProps, NotificationRequestFormState> {
    constructor(props: NotificationRequestFormProps) {
        super(props);
@@ -57,7 +58,7 @@
                header: "",
                message: ""
            }
        }
        };
    }
    private static getEmptyFields(): AnimalNotificationRequest {
@@ -86,7 +87,7 @@
            <React.Fragment>
                {this.state.isSubmitting ? this.renderLoader() : this.renderForm()}
            </React.Fragment>
        )
        );
    }
    public renderForm() {
@@ -176,14 +177,14 @@
                        onChange={this.handleApproximateSizeChange.bind(this)}
                        aria-label="Select approximate size">
                        <FormSelectOption label={"None"}
                                          value={null}
                                          key={"None"}/>
                            value={null}
                            key={"None"}/>
                        {Object.keys(ApproximateSize).map((approximateSize) => {
                            return <FormSelectOption
                                key={approximateSize}
                                value={approximateSize}
                                label={approximateSize}
                            />
                            />;
                        })}
                    </FormSelect>
                </FormGroup>
@@ -191,7 +192,7 @@
                    <Button variant="primary" type={ButtonType.submit}>Subscribe</Button>
                </ActionGroup>
            </Form>
        )
        );
    }
    private handleNameChange(username: string) {
adopt-a-pup/web-app/src/Models/AnimalNotificationRequest.ts
@@ -1,5 +1,3 @@
import {ApproximateSize} from "./ApproximateSize";
export  interface AnimalNotificationRequest {
    username: string,
    email: string,
adopt-a-pup/web-app/src/Services/AnimalFakeService.ts
@@ -73,7 +73,7 @@
    }
    public async subscribeNotifications(animalNotificationRequest: AnimalNotificationRequest): Promise<void> {
        // Do something?
        console.log("AnimalFakeService.subscribeNotifications", animalNotificationRequest);
    }
    public async getById(): Promise<Animal> {
adopt-a-pup/web-app/src/Views/AnimalCreateView.tsx
@@ -27,7 +27,10 @@
                <PageSection>
                    <Card>
                        <CardBody>
                            <AnimalCreateForm animalService={this.props.animalService} shelterService={this.props.shelterService} />
                            <AnimalCreateForm
                                animalService={this.props.animalService}
                                shelterService={this.props.shelterService}
                            />
                        </CardBody>
                    </Card>
                </PageSection>
adopt-a-pup/web-app/src/Views/NotificationsView.tsx
@@ -21,6 +21,6 @@
                    <NotificationRequestForm animalService={this.props.animalService}/>
                </PageSection>
            </React.Fragment>
        )
        );
    }
}