From d4efcf556bee5599b87a18da9420df2143e1c757 Mon Sep 17 00:00:00 2001
From: Jaime Ramírez <jaime.ramirez@redhat.com>
Date: Thu, 11 Jun 2020 13:09:28 +0200
Subject: [PATCH] Fix lint and tests (#46)

---
 adopt-a-pup/web-app/src/App.tsx                                |    2 +-
 adopt-a-pup/web-app/src/Models/AnimalNotificationRequest.ts    |    2 --
 adopt-a-pup/web-app/.eslintrc.json                             |    2 +-
 adopt-a-pup/web-app/src/Components/AdoptionForm.test.tsx       |    2 +-
 adopt-a-pup/web-app/src/Services/AnimalFakeService.ts          |    2 +-
 adopt-a-pup/web-app/src/Views/AnimalCreateView.tsx             |    5 ++++-
 adopt-a-pup/web-app/src/Views/NotificationsView.tsx            |    2 +-
 adopt-a-pup/web-app/src/Components/AnimalCreateForm.tsx        |   11 ++++++-----
 adopt-a-pup/web-app/src/Components/NotificationRequestForm.tsx |   15 ++++++++-------
 9 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/adopt-a-pup/web-app/.eslintrc.json b/adopt-a-pup/web-app/.eslintrc.json
index 7b3bb94..1543931 100644
--- a/adopt-a-pup/web-app/.eslintrc.json
+++ b/adopt-a-pup/web-app/.eslintrc.json
@@ -27,7 +27,7 @@
     "rules": {
         "max-len": [
             "error",
-            100
+            120
         ],
         "indent": [
             "error",
diff --git a/adopt-a-pup/web-app/src/App.tsx b/adopt-a-pup/web-app/src/App.tsx
index 8eecfe6..b599c5e 100644
--- a/adopt-a-pup/web-app/src/App.tsx
+++ b/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>
diff --git a/adopt-a-pup/web-app/src/Components/AdoptionForm.test.tsx b/adopt-a-pup/web-app/src/Components/AdoptionForm.test.tsx
index 9d9ed82..4c9978d 100644
--- a/adopt-a-pup/web-app/src/Components/AdoptionForm.test.tsx
+++ b/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", () => {
diff --git a/adopt-a-pup/web-app/src/Components/AnimalCreateForm.tsx b/adopt-a-pup/web-app/src/Components/AnimalCreateForm.tsx
index 8ad6297..33e1718 100644
--- a/adopt-a-pup/web-app/src/Components/AnimalCreateForm.tsx
+++ b/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>
diff --git a/adopt-a-pup/web-app/src/Components/NotificationRequestForm.tsx b/adopt-a-pup/web-app/src/Components/NotificationRequestForm.tsx
index eac46c8..e6f53a6 100644
--- a/adopt-a-pup/web-app/src/Components/NotificationRequestForm.tsx
+++ b/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) {
diff --git a/adopt-a-pup/web-app/src/Models/AnimalNotificationRequest.ts b/adopt-a-pup/web-app/src/Models/AnimalNotificationRequest.ts
index 41b99d0..1ecb415 100644
--- a/adopt-a-pup/web-app/src/Models/AnimalNotificationRequest.ts
+++ b/adopt-a-pup/web-app/src/Models/AnimalNotificationRequest.ts
@@ -1,5 +1,3 @@
-import {ApproximateSize} from "./ApproximateSize";
-
 export  interface AnimalNotificationRequest {
     username: string,
     email: string,
diff --git a/adopt-a-pup/web-app/src/Services/AnimalFakeService.ts b/adopt-a-pup/web-app/src/Services/AnimalFakeService.ts
index 5814524..98f9c57 100644
--- a/adopt-a-pup/web-app/src/Services/AnimalFakeService.ts
+++ b/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> {
diff --git a/adopt-a-pup/web-app/src/Views/AnimalCreateView.tsx b/adopt-a-pup/web-app/src/Views/AnimalCreateView.tsx
index b09b2fa..4d05514 100644
--- a/adopt-a-pup/web-app/src/Views/AnimalCreateView.tsx
+++ b/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>
diff --git a/adopt-a-pup/web-app/src/Views/NotificationsView.tsx b/adopt-a-pup/web-app/src/Views/NotificationsView.tsx
index 4062f0f..a3446db 100644
--- a/adopt-a-pup/web-app/src/Views/NotificationsView.tsx
+++ b/adopt-a-pup/web-app/src/Views/NotificationsView.tsx
@@ -21,6 +21,6 @@
                     <NotificationRequestForm animalService={this.props.animalService}/>
                 </PageSection>
             </React.Fragment>
-        )
+        );
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3