mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
Add test for the alerts
This commit is contained in:
@@ -3,7 +3,7 @@ describe('ErrorResponse', () => {
|
||||
test('should return a valid error response object', () => {
|
||||
const errorResponseObject: ErrorResponse = new ErrorResponse(500, {
|
||||
error: 'Internal Server Error',
|
||||
});
|
||||
},{});
|
||||
expect(errorResponseObject.statusCode).toBe(500);
|
||||
expect(errorResponseObject.data).toEqual({
|
||||
error: 'Internal Server Error',
|
||||
|
||||
@@ -5,12 +5,12 @@ describe('Response()', () => {
|
||||
test('should return a valid response object', () => {
|
||||
const responseObject: Response<JSONObject> = new Response(200, {
|
||||
welcome: 'here',
|
||||
});
|
||||
},{});
|
||||
expect(responseObject.statusCode).toBe(200);
|
||||
expect(responseObject.data).toEqual({ welcome: 'here' });
|
||||
const responseObjectArray: Response<Array<JSONObject>> = new Response<
|
||||
Array<JSONObject>
|
||||
>(200, [{ welcome: 'here' }]);
|
||||
>(200, [{ welcome: 'here' }], {});
|
||||
expect(responseObjectArray.statusCode).toBe(200);
|
||||
expect(responseObjectArray.data).toEqual([{ welcome: 'here' }]);
|
||||
});
|
||||
|
||||
37
Common/Tests/Types/Alerts/AlertEventType.test.ts
Normal file
37
Common/Tests/Types/Alerts/AlertEventType.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
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');
|
||||
});
|
||||
test('AlertEventType.InvestigationNoteUpdated to Investigation note updated', () => {
|
||||
expect(AlertEventType.InvestigationNoteUpdated).toBe('Investigation note updated');
|
||||
});
|
||||
test('AlertEventType.ScheduledMaintenanceCreated to 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');
|
||||
});
|
||||
|
||||
test('AlertEventType.ScheduledMaintenanceResolved to sheduled mantainance resolved', () => {
|
||||
expect(AlertEventType.ScheduledMaintenanceResolved).toBe('Scheduled maintenance resolved');
|
||||
});
|
||||
test('AlertEventType.Acknowledged to Scheduled maintenance cancelled', () => {
|
||||
expect(AlertEventType.ScheduledMaintenanceCancelled).toBe('Scheduled maintenance cancelled');
|
||||
});
|
||||
test('AlertEventType.AnnouncementNotificationCreated to Announcement notification created', () => {
|
||||
expect(AlertEventType.AnnouncementNotificationCreated).toBe('Announcement notification created');
|
||||
});
|
||||
});
|
||||
23
Common/Tests/Types/Alerts/AlertType.test.ts
Normal file
23
Common/Tests/Types/Alerts/AlertType.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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');
|
||||
});
|
||||
|
||||
});
|
||||
16
Common/Tests/Types/ApplicationLog/ApplicationLogType.test.ts
Normal file
16
Common/Tests/Types/ApplicationLog/ApplicationLogType.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
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');
|
||||
});
|
||||
|
||||
});
|
||||
16
Common/Tests/Types/Code/CodeType.test.ts
Normal file
16
Common/Tests/Types/Code/CodeType.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
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');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,19 +1,20 @@
|
||||
import LIMIT_MAX, { LIMIT_PER_PROJECT } from '../../../Types/Database/LimitMax';
|
||||
|
||||
describe('LIMIT_MAX', () => {
|
||||
test('it should ', () => {
|
||||
expect(LIMIT_MAX).toEqual(1000);
|
||||
test('it should be number', () => {
|
||||
expect(typeof LIMIT_MAX).toBe("number")
|
||||
});
|
||||
});
|
||||
|
||||
describe('LIMIT_MAX', () => {
|
||||
test('it should have a value', () => {
|
||||
expect(LIMIT_MAX).toEqual(1000);
|
||||
test('it be positive', () => {
|
||||
expect(LIMIT_MAX).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('LIMIT_PER_PROJECT', () => {
|
||||
test('it should have a value ', () => {
|
||||
expect(LIMIT_PER_PROJECT).toEqual(100);
|
||||
test('should be positive number', () => {
|
||||
expect(typeof LIMIT_PER_PROJECT).toBe("number")
|
||||
expect(LIMIT_PER_PROJECT).toBeGreaterThan(0)
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,9 +6,10 @@ describe('Email()', () => {
|
||||
});
|
||||
|
||||
test('should not create an email with invalid credentials', () => {
|
||||
let invalidEmail='invalid email address'
|
||||
expect(() => {
|
||||
new Email('invalid email address');
|
||||
}).toThrow('Email is not in valid format.');
|
||||
new Email(invalidEmail);
|
||||
}).toThrow(`Email ${invalidEmail} is not in valid format.`);
|
||||
});
|
||||
|
||||
test('should be a business email', () => {
|
||||
|
||||
@@ -23,13 +23,16 @@ describe('Testing Class Phone', () => {
|
||||
});
|
||||
|
||||
test('try to mutating Phone.phone with invalid value should throw an BadDataExcepection', () => {
|
||||
const value: Phone = new Phone('+251912974103');
|
||||
let valid='+251912974103'
|
||||
let invalid='278@$90> '
|
||||
const value: Phone = new Phone(valid);
|
||||
expect(() => {
|
||||
value.phone = '567';
|
||||
value.phone = invalid;
|
||||
}).toThrowError(BadDataException);
|
||||
expect(() => {
|
||||
value.phone = '278@$90> ';
|
||||
}).toThrow('Phone is not in valid format.');
|
||||
}).toThrow('Phone is not in valid format: 278@$90>');
|
||||
expect(value.phone).toBe(valid)
|
||||
expect(() => {
|
||||
value.phone = 'hgjuit879';
|
||||
}).toThrowError(BadDataException);
|
||||
|
||||
@@ -9,10 +9,10 @@ describe('Testing class port', () => {
|
||||
expect(new Port('6000').port.positiveNumber).toEqual(6000);
|
||||
});
|
||||
|
||||
test('should throw exception "Port should be in the range from 0 to 65535"', () => {
|
||||
test('should throw exception "Port is not in valid format."', () => {
|
||||
expect(() => {
|
||||
new Port(67000);
|
||||
}).toThrow('Port should be in the range from 0 to 65535');
|
||||
}).toThrow('Port is not in valid format.');
|
||||
});
|
||||
|
||||
test('Port.port should be mutatable', () => {
|
||||
|
||||
@@ -6,7 +6,7 @@ enum AlertEventType {
|
||||
InvestigationNoteUpdated = 'Investigation note updated',
|
||||
ScheduledMaintenanceCreated = 'Scheduled maintenance created',
|
||||
ScheduledMaintenanceNoteCreated = 'Scheduled maintenance note created',
|
||||
ScheduledMaintenanceEesolved = 'Scheduled maintenance resolved',
|
||||
ScheduledMaintenanceResolved = 'Scheduled maintenance resolved',
|
||||
ScheduledMaintenanceCancelled = 'Scheduled maintenance cancelled',
|
||||
AnnouncementNotificationCreated = 'Announcement notification created',
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
enum ApplicationLogType {
|
||||
Info = 'Info',
|
||||
Erorr = 'Error',
|
||||
Error = 'Error',
|
||||
Warning = 'Warning',
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ enum CodeType {
|
||||
JavaScript = 'JavaScript',
|
||||
CSS = 'CSS',
|
||||
HTML = 'HTML',
|
||||
|
||||
// TODO add more mime types.
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user