-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
88 changed files
with
860 additions
and
804 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* @flow */ | ||
/* global jest, test, expect */ | ||
import NotifmeSdk from '../../../src' | ||
import mockHttp, {mockResponse} from '../mockHttp' | ||
import mockHttp, { mockResponse } from '../mockHttp' | ||
|
||
jest.mock('../../../src/util/logger', () => ({ | ||
warn: jest.fn() | ||
|
@@ -29,7 +29,7 @@ const request = { | |
} | ||
|
||
test('Mailgun success with minimal parameters.', async () => { | ||
mockResponse(200, JSON.stringify({id: 'returned-id'})) | ||
mockResponse(200, JSON.stringify({ id: 'returned-id' })) | ||
const result = await sdk.send(request) | ||
expect(mockHttp).lastCalledWith(expect.objectContaining({ | ||
hostname: 'api.mailgun.net', | ||
|
@@ -48,13 +48,13 @@ test('Mailgun success with minimal parameters.', async () => { | |
expect(result).toEqual({ | ||
status: 'success', | ||
channels: { | ||
email: {id: 'returned-id', providerId: 'email-mailgun-provider'} | ||
email: { id: 'returned-id', providerId: 'email-mailgun-provider' } | ||
} | ||
}) | ||
}) | ||
|
||
test('Mailgun success with all parameters.', async () => { | ||
mockResponse(200, JSON.stringify({id: 'returned-id'})) | ||
mockResponse(200, JSON.stringify({ id: 'returned-id' })) | ||
const completeRequest = { | ||
metadata: { | ||
id: '24', | ||
|
@@ -66,7 +66,7 @@ test('Mailgun success with all parameters.', async () => { | |
subject: 'Hi John', | ||
html: '<b>Hello John! How are you?</b>', | ||
replyTo: '[email protected]', | ||
headers: {'My-Custom-Header': 'my-value'}, | ||
headers: { 'My-Custom-Header': 'my-value' }, | ||
cc: ['[email protected]', '[email protected]'], | ||
bcc: ['[email protected]'], | ||
attachments: [{ | ||
|
@@ -94,21 +94,21 @@ test('Mailgun success with all parameters.', async () => { | |
expect(result).toEqual({ | ||
status: 'success', | ||
channels: { | ||
email: {id: 'returned-id', providerId: 'email-mailgun-provider'} | ||
email: { id: 'returned-id', providerId: 'email-mailgun-provider' } | ||
} | ||
}) | ||
}) | ||
|
||
test('Mailgun API error.', async () => { | ||
mockResponse(400, JSON.stringify({message: 'error!'})) | ||
mockResponse(400, JSON.stringify({ message: 'error!' })) | ||
const result = await sdk.send(request) | ||
expect(result).toEqual({ | ||
status: 'error', | ||
errors: { | ||
email: '400 - error!' | ||
}, | ||
channels: { | ||
email: {id: undefined, providerId: 'email-mailgun-provider'} | ||
email: { id: undefined, providerId: 'email-mailgun-provider' } | ||
} | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* @flow */ | ||
/* global jest, test, expect */ | ||
import NotifmeSdk from '../../../src' | ||
import mockHttp, {mockResponse} from '../mockHttp' | ||
import mockHttp, { mockResponse } from '../mockHttp' | ||
|
||
jest.mock('../../../src/util/logger', () => ({ | ||
warn: jest.fn() | ||
|
@@ -50,7 +50,7 @@ test('Sendgrid success with minimal parameters.', async () => { | |
expect(result).toEqual({ | ||
status: 'success', | ||
channels: { | ||
email: {id: expect.stringMatching(/\w*/), providerId: 'email-sendgrid-provider'} | ||
email: { id: expect.stringMatching(/\w*/), providerId: 'email-sendgrid-provider' } | ||
} | ||
}) | ||
}) | ||
|
@@ -68,7 +68,7 @@ test('Sendgrid success with all parameters.', async () => { | |
subject: 'Hi John', | ||
html: '<b>Hello John! How are you?</b>', | ||
replyTo: '[email protected]', | ||
headers: {'My-Custom-Header': 'my-value'}, | ||
headers: { 'My-Custom-Header': 'my-value' }, | ||
cc: ['[email protected]', '[email protected]'], | ||
bcc: ['[email protected]'], | ||
attachments: [{ | ||
|
@@ -99,7 +99,7 @@ test('Sendgrid success with all parameters.', async () => { | |
expect(result).toEqual({ | ||
status: 'success', | ||
channels: { | ||
email: {id: '24', providerId: 'email-sendgrid-provider'} | ||
email: { id: '24', providerId: 'email-sendgrid-provider' } | ||
} | ||
}) | ||
}) | ||
|
@@ -143,21 +143,21 @@ test('Sendgrid success with buffered attachment.', async () => { | |
expect(result).toEqual({ | ||
status: 'success', | ||
channels: { | ||
email: {id: '24', providerId: 'email-sendgrid-provider'} | ||
email: { id: '24', providerId: 'email-sendgrid-provider' } | ||
} | ||
}) | ||
}) | ||
|
||
test('Sendgrid API error.', async () => { | ||
mockResponse(400, JSON.stringify({errors: [{code: '24', message: 'error!'}]})) | ||
mockResponse(400, JSON.stringify({ errors: [{ code: '24', message: 'error!' }] })) | ||
const result = await sdk.send(request) | ||
expect(result).toEqual({ | ||
status: 'error', | ||
errors: { | ||
email: '400 - code: 24, message: error!' | ||
}, | ||
channels: { | ||
email: {id: undefined, providerId: 'email-sendgrid-provider'} | ||
email: { id: undefined, providerId: 'email-sendgrid-provider' } | ||
} | ||
}) | ||
}) |
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
Oops, something went wrong.