-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move config variable and .env variables
- Loading branch information
Showing
4 changed files
with
45 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import sinonChai from 'sinon-chai'; | |
import { ApiError } from '../errors/custom-error'; | ||
import { GCNotifyService } from './gcnotify-service'; | ||
import axios from 'axios'; | ||
import { IgcNotifyGenericMessage, IgcNotifyConfig } from '../models/gcnotify'; | ||
import { IgcNotifyGenericMessage } from '../models/gcnotify'; | ||
|
||
chai.use(sinonChai); | ||
|
||
|
@@ -17,40 +17,20 @@ describe('GCNotifyService', () => { | |
|
||
const emailAddress = '[email protected]'; | ||
|
||
const config = { | ||
headers: { | ||
Authorization: 'api_key', | ||
'Content-Type': 'application/json' | ||
} | ||
}; | ||
|
||
const message = { | ||
header: 'message.header', | ||
body1: 'message.body1', | ||
body2: 'message.body2', | ||
footer: 'message.footer' | ||
}; | ||
|
||
it('should throw a 400 error when no url is given', async () => { | ||
const gcNotifyServiece = new GCNotifyService(); | ||
|
||
sinon.stub(axios, 'post').resolves({ data: null }); | ||
|
||
try { | ||
await gcNotifyServiece.sendEmailGCNotification('', config, message); | ||
expect.fail(); | ||
} catch (actualError) { | ||
expect((actualError as ApiError).message).to.equal('Failed to send Notification'); | ||
} | ||
}); | ||
|
||
it('should throw a 400 error when no config is given', async () => { | ||
it('should throw a 400 error when no email is given', async () => { | ||
const gcNotifyServiece = new GCNotifyService(); | ||
|
||
sinon.stub(axios, 'post').resolves({ data: null }); | ||
|
||
try { | ||
await gcNotifyServiece.sendEmailGCNotification(emailAddress, {} as IgcNotifyConfig, message); | ||
await gcNotifyServiece.sendEmailGCNotification('', message); | ||
expect.fail(); | ||
} catch (actualError) { | ||
expect((actualError as ApiError).message).to.equal('Failed to send Notification'); | ||
|
@@ -63,7 +43,7 @@ describe('GCNotifyService', () => { | |
sinon.stub(axios, 'post').resolves({ data: null }); | ||
|
||
try { | ||
await gcNotifyServiece.sendEmailGCNotification(emailAddress, config, message); | ||
await gcNotifyServiece.sendEmailGCNotification(emailAddress, message); | ||
expect.fail(); | ||
} catch (actualError) { | ||
expect((actualError as ApiError).message).to.equal('Failed to send Notification'); | ||
|
@@ -75,11 +55,7 @@ describe('GCNotifyService', () => { | |
|
||
sinon.stub(axios, 'post').resolves({ data: 201 }); | ||
|
||
const result = await gcNotifyServiece.sendEmailGCNotification( | ||
emailAddress, | ||
config, | ||
{} as IgcNotifyGenericMessage | ||
); | ||
const result = await gcNotifyServiece.sendEmailGCNotification(emailAddress, {} as IgcNotifyGenericMessage); | ||
|
||
expect(result).to.eql(201); | ||
}); | ||
|
@@ -92,40 +68,20 @@ describe('GCNotifyService', () => { | |
|
||
const sms = '2501231234'; | ||
|
||
const config = { | ||
headers: { | ||
Authorization: 'api_key', | ||
'Content-Type': 'application/json' | ||
} | ||
}; | ||
|
||
const message = { | ||
header: 'message.header', | ||
body1: 'message.body1', | ||
body2: 'message.body2', | ||
footer: 'message.footer' | ||
}; | ||
|
||
it('should throw a 400 error when no url is given', async () => { | ||
const gcNotifyServiece = new GCNotifyService(); | ||
|
||
sinon.stub(axios, 'post').resolves({ data: null }); | ||
|
||
try { | ||
await gcNotifyServiece.sendPhoneNumberGCNotification('', config, message); | ||
expect.fail(); | ||
} catch (actualError) { | ||
expect((actualError as ApiError).message).to.equal('Failed to send Notification'); | ||
} | ||
}); | ||
|
||
it('should throw a 400 error when no config is given', async () => { | ||
it('should throw a 400 error when no phone number is given', async () => { | ||
const gcNotifyServiece = new GCNotifyService(); | ||
|
||
sinon.stub(axios, 'post').resolves({ data: null }); | ||
|
||
try { | ||
await gcNotifyServiece.sendPhoneNumberGCNotification(sms, {} as IgcNotifyConfig, message); | ||
await gcNotifyServiece.sendPhoneNumberGCNotification('', message); | ||
expect.fail(); | ||
} catch (actualError) { | ||
expect((actualError as ApiError).message).to.equal('Failed to send Notification'); | ||
|
@@ -138,7 +94,7 @@ describe('GCNotifyService', () => { | |
sinon.stub(axios, 'post').resolves({ data: null }); | ||
|
||
try { | ||
await gcNotifyServiece.sendPhoneNumberGCNotification(sms, config, message); | ||
await gcNotifyServiece.sendPhoneNumberGCNotification(sms, message); | ||
expect.fail(); | ||
} catch (actualError) { | ||
expect((actualError as ApiError).message).to.equal('Failed to send Notification'); | ||
|
@@ -150,7 +106,7 @@ describe('GCNotifyService', () => { | |
|
||
sinon.stub(axios, 'post').resolves({ data: 201 }); | ||
|
||
const result = await gcNotifyServiece.sendPhoneNumberGCNotification(sms, config, {} as IgcNotifyGenericMessage); | ||
const result = await gcNotifyServiece.sendPhoneNumberGCNotification(sms, {} as IgcNotifyGenericMessage); | ||
|
||
expect(result).to.eql(201); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters