From 3fea02df2266fe57f20256c498a4dad12bd0d951 Mon Sep 17 00:00:00 2001 From: Sostene Munezero Bagira Date: Tue, 7 Feb 2023 15:34:56 +0200 Subject: [PATCH] fix eslint errors --- .github/workflows/test.common.yaml | 4 +- Common/Tests/Types/API/ErrorResponse.test.ts | 10 ++-- Common/Tests/Types/API/Response.test.ts | 10 ++-- .../Tests/Types/Alerts/AlertEventType.test.ts | 50 ++++++++++++------- Common/Tests/Types/Alerts/AlertType.test.ts | 12 ++--- .../ApplicationLog/ApplicationLogType.test.ts | 7 +-- Common/Tests/Types/Code/CodeType.test.ts | 7 +-- Common/Tests/Types/Database/LimitMax.test.ts | 6 +-- Common/Tests/Types/Email/Email.test.ts | 2 +- Common/Tests/Types/Phone.test.ts | 6 +-- Common/Types/Code/CodeType.ts | 2 +- 11 files changed, 63 insertions(+), 53 deletions(-) diff --git a/.github/workflows/test.common.yaml b/.github/workflows/test.common.yaml index 73b33ac1f6..112e97fdbb 100644 --- a/.github/workflows/test.common.yaml +++ b/.github/workflows/test.common.yaml @@ -17,6 +17,6 @@ jobs: - uses: actions/setup-node@v2 with: check-latest: true - - run: cd Common && npm install - - run: cd Model && npm install && npm run test + - run: cd Model && npm install + - run: cd Common && npm install && npm run test \ No newline at end of file diff --git a/Common/Tests/Types/API/ErrorResponse.test.ts b/Common/Tests/Types/API/ErrorResponse.test.ts index 82c7ffe2ac..0c908815b4 100644 --- a/Common/Tests/Types/API/ErrorResponse.test.ts +++ b/Common/Tests/Types/API/ErrorResponse.test.ts @@ -1,9 +1,13 @@ import ErrorResponse from '../../../Types/API/HTTPErrorResponse'; describe('ErrorResponse', () => { test('should return a valid error response object', () => { - const errorResponseObject: ErrorResponse = new ErrorResponse(500, { - error: 'Internal Server Error', - },{}); + const errorResponseObject: ErrorResponse = new ErrorResponse( + 500, + { + error: 'Internal Server Error', + }, + {} + ); expect(errorResponseObject.statusCode).toBe(500); expect(errorResponseObject.data).toEqual({ error: 'Internal Server Error', diff --git a/Common/Tests/Types/API/Response.test.ts b/Common/Tests/Types/API/Response.test.ts index eb7398a5c3..0a017b9830 100644 --- a/Common/Tests/Types/API/Response.test.ts +++ b/Common/Tests/Types/API/Response.test.ts @@ -3,9 +3,13 @@ import { JSONObject } from '../../../Types/JSON'; describe('Response()', () => { test('should return a valid response object', () => { - const responseObject: Response = new Response(200, { - welcome: 'here', - },{}); + const responseObject: Response = new Response( + 200, + { + welcome: 'here', + }, + {} + ); expect(responseObject.statusCode).toBe(200); expect(responseObject.data).toEqual({ welcome: 'here' }); const responseObjectArray: Response> = new Response< diff --git a/Common/Tests/Types/Alerts/AlertEventType.test.ts b/Common/Tests/Types/Alerts/AlertEventType.test.ts index 09ca86efa4..9140fe2fa8 100644 --- a/Common/Tests/Types/Alerts/AlertEventType.test.ts +++ b/Common/Tests/Types/Alerts/AlertEventType.test.ts @@ -1,37 +1,49 @@ import AlertEventType from '../../../Types/Alerts/AlertEventType'; - - describe('AlertEventType', () => { test('AlertEventType.Identified to be Identified', () => { expect(AlertEventType.Identified).toBe('Identified'); }); test('AlertEventType.Acknowledged to Acknowledged', () => { expect(AlertEventType.Acknowledged).toBe('Acknowledged'); - }); + }); test('AlertEventType.Resolved to Resolved', () => { expect(AlertEventType.Resolved).toBe('Resolved'); - }); + }); test('AlertEventType.InvestigationNoteCreated to Investigation note created', () => { - expect(AlertEventType.InvestigationNoteCreated).toBe('Investigation note created'); - }); + expect(AlertEventType.InvestigationNoteCreated).toBe( + 'Investigation note created' + ); + }); test('AlertEventType.InvestigationNoteUpdated to Investigation note updated', () => { - expect(AlertEventType.InvestigationNoteUpdated).toBe('Investigation note updated'); - }); + expect(AlertEventType.InvestigationNoteUpdated).toBe( + 'Investigation note updated' + ); + }); test('AlertEventType.ScheduledMaintenanceCreated to Scheduled maintenance created', () => { - expect(AlertEventType.ScheduledMaintenanceCreated).toBe('Scheduled maintenance created'); - }); + expect(AlertEventType.ScheduledMaintenanceCreated).toBe( + 'Scheduled maintenance created' + ); + }); test('AlertEventType.ScheduledMaintenanceNoteCreated to Scheduled maintenance note Created', () => { - expect(AlertEventType.ScheduledMaintenanceNoteCreated).toBe('Scheduled maintenance note created'); - }); - + expect(AlertEventType.ScheduledMaintenanceNoteCreated).toBe( + 'Scheduled maintenance note created' + ); + }); + test('AlertEventType.ScheduledMaintenanceResolved to sheduled mantainance resolved', () => { - expect(AlertEventType.ScheduledMaintenanceResolved).toBe('Scheduled maintenance resolved'); - }); + expect(AlertEventType.ScheduledMaintenanceResolved).toBe( + 'Scheduled maintenance resolved' + ); + }); test('AlertEventType.Acknowledged to Scheduled maintenance cancelled', () => { - expect(AlertEventType.ScheduledMaintenanceCancelled).toBe('Scheduled maintenance cancelled'); - }); + expect(AlertEventType.ScheduledMaintenanceCancelled).toBe( + 'Scheduled maintenance cancelled' + ); + }); test('AlertEventType.AnnouncementNotificationCreated to Announcement notification created', () => { - expect(AlertEventType.AnnouncementNotificationCreated).toBe('Announcement notification created'); - }); + expect(AlertEventType.AnnouncementNotificationCreated).toBe( + 'Announcement notification created' + ); + }); }); diff --git a/Common/Tests/Types/Alerts/AlertType.test.ts b/Common/Tests/Types/Alerts/AlertType.test.ts index e875a4cfe3..7217665d78 100644 --- a/Common/Tests/Types/Alerts/AlertType.test.ts +++ b/Common/Tests/Types/Alerts/AlertType.test.ts @@ -1,23 +1,19 @@ import AlertType from '../../../Types/Alerts/AlertType'; - - describe('AlertType', () => { - test('AlertType.Email to be Email', () => { expect(AlertType.Webhook).toBe('Webhook'); }); test('AlertType.Acknowledged to Acknowledged', () => { expect(AlertType.Email).toBe('Email'); - }); + }); test('AlertType.SMS to SMS', () => { expect(AlertType.SMS).toBe('SMS'); - }); + }); test('AlertType.Call to Call', () => { expect(AlertType.Call).toBe('Call'); - }); + }); test('AlertType.PushNotification to PushNotification', () => { expect(AlertType.PushNotification).toBe('PushNotification'); - }); - + }); }); diff --git a/Common/Tests/Types/ApplicationLog/ApplicationLogType.test.ts b/Common/Tests/Types/ApplicationLog/ApplicationLogType.test.ts index 07e7f749fd..81adfdf24b 100644 --- a/Common/Tests/Types/ApplicationLog/ApplicationLogType.test.ts +++ b/Common/Tests/Types/ApplicationLog/ApplicationLogType.test.ts @@ -1,16 +1,13 @@ import ApplicationLogType from '../../../Types/ApplicationLog/ApplicationLogType'; - - describe('ApplicationLogType', () => { test('ApplicationLogType.Info to be Info', () => { expect(ApplicationLogType.Info).toBe('Info'); }); test('ApplicationLogType.Error to Error', () => { expect(ApplicationLogType.Error).toBe('Error'); - }); + }); test('ApplicationLogType.Warning to Warning', () => { expect(ApplicationLogType.Warning).toBe('Warning'); - }); - + }); }); diff --git a/Common/Tests/Types/Code/CodeType.test.ts b/Common/Tests/Types/Code/CodeType.test.ts index 07e7f749fd..81adfdf24b 100644 --- a/Common/Tests/Types/Code/CodeType.test.ts +++ b/Common/Tests/Types/Code/CodeType.test.ts @@ -1,16 +1,13 @@ import ApplicationLogType from '../../../Types/ApplicationLog/ApplicationLogType'; - - describe('ApplicationLogType', () => { test('ApplicationLogType.Info to be Info', () => { expect(ApplicationLogType.Info).toBe('Info'); }); test('ApplicationLogType.Error to Error', () => { expect(ApplicationLogType.Error).toBe('Error'); - }); + }); test('ApplicationLogType.Warning to Warning', () => { expect(ApplicationLogType.Warning).toBe('Warning'); - }); - + }); }); diff --git a/Common/Tests/Types/Database/LimitMax.test.ts b/Common/Tests/Types/Database/LimitMax.test.ts index 547acda138..b37b04e7b8 100644 --- a/Common/Tests/Types/Database/LimitMax.test.ts +++ b/Common/Tests/Types/Database/LimitMax.test.ts @@ -2,7 +2,7 @@ import LIMIT_MAX, { LIMIT_PER_PROJECT } from '../../../Types/Database/LimitMax'; describe('LIMIT_MAX', () => { test('it should be number', () => { - expect(typeof LIMIT_MAX).toBe("number") + expect(typeof LIMIT_MAX).toBe('number'); }); }); @@ -14,7 +14,7 @@ describe('LIMIT_MAX', () => { describe('LIMIT_PER_PROJECT', () => { test('should be positive number', () => { - expect(typeof LIMIT_PER_PROJECT).toBe("number") - expect(LIMIT_PER_PROJECT).toBeGreaterThan(0) + expect(typeof LIMIT_PER_PROJECT).toBe('number'); + expect(LIMIT_PER_PROJECT).toBeGreaterThan(0); }); }); diff --git a/Common/Tests/Types/Email/Email.test.ts b/Common/Tests/Types/Email/Email.test.ts index 97adb2d948..00e6d2c39e 100644 --- a/Common/Tests/Types/Email/Email.test.ts +++ b/Common/Tests/Types/Email/Email.test.ts @@ -6,7 +6,7 @@ describe('Email()', () => { }); test('should not create an email with invalid credentials', () => { - let invalidEmail='invalid email address' + const invalidEmail: string = 'invalid email address'; expect(() => { new Email(invalidEmail); }).toThrow(`Email ${invalidEmail} is not in valid format.`); diff --git a/Common/Tests/Types/Phone.test.ts b/Common/Tests/Types/Phone.test.ts index d4d29e3d8a..6b83757677 100644 --- a/Common/Tests/Types/Phone.test.ts +++ b/Common/Tests/Types/Phone.test.ts @@ -23,8 +23,8 @@ describe('Testing Class Phone', () => { }); test('try to mutating Phone.phone with invalid value should throw an BadDataExcepection', () => { - let valid='+251912974103' - let invalid='278@$90> ' + const valid: string = '+251912974103'; + const invalid: string = '278@$90> '; const value: Phone = new Phone(valid); expect(() => { value.phone = invalid; @@ -32,7 +32,7 @@ describe('Testing Class Phone', () => { expect(() => { value.phone = '278@$90> '; }).toThrow('Phone is not in valid format: 278@$90>'); - expect(value.phone).toBe(valid) + expect(value.phone).toBe(valid); expect(() => { value.phone = 'hgjuit879'; }).toThrowError(BadDataException); diff --git a/Common/Types/Code/CodeType.ts b/Common/Types/Code/CodeType.ts index 533f261e6a..66603793c6 100644 --- a/Common/Types/Code/CodeType.ts +++ b/Common/Types/Code/CodeType.ts @@ -2,7 +2,7 @@ enum CodeType { JavaScript = 'JavaScript', CSS = 'CSS', HTML = 'HTML', - + // TODO add more mime types. }