-
Notifications
You must be signed in to change notification settings - Fork 109
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
1 parent
777aa84
commit bf05ab6
Showing
19 changed files
with
1,055 additions
and
54 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import formData from 'form-data'; | ||
|
||
import nock from 'nock'; | ||
import Request from '../lib/Classes/common/Request'; | ||
|
||
import { InputFormData, RequestOptions } from '../lib/Types/Common'; | ||
|
||
import { IInboxPlacementsClient } from '../lib/Interfaces'; | ||
import InboxPlacementsClient from '../lib/Classes/InboxPlacements/inboxPlacements'; | ||
|
||
import SeedsListsClient from '../lib/Classes/InboxPlacements/SeedsLists/SeedsListsClient'; | ||
import InboxPlacementsResultsClient from '../lib/Classes/InboxPlacements/Results/InboxPlacementsResultsClient'; | ||
import InboxPlacementsProvidersClient from '../lib/Classes/InboxPlacements/providers/InboxPlacementsProviders'; | ||
|
||
|
||
// TODO: fix types | ||
describe('Inbox Placements Client', () => { | ||
let client: IInboxPlacementsClient; | ||
let api: nock.Scope; | ||
|
||
beforeEach(() => { | ||
const reqObject = new Request({ url: 'https://api.mailgun.net' } as RequestOptions, formData as InputFormData); | ||
client = new InboxPlacementsClient( | ||
reqObject, | ||
{} as SeedsListsClient, | ||
{} as InboxPlacementsResultsClient, | ||
{} as InboxPlacementsProvidersClient | ||
); | ||
api = nock('https://api.mailgun.net'); | ||
}); | ||
|
||
afterEach(() => { | ||
api.done(); | ||
}); | ||
|
||
describe('runTest', () => { | ||
it('runs inbox placements test', async () => { | ||
const providers = [ | ||
{ | ||
domain: 'aol.com', | ||
display_name: 'AOL', | ||
region: 'Global', | ||
created_at: '2023-01-04T17:40:03.400Z', | ||
updated_at: '2023-02-17T17:20:12.172Z' | ||
}, | ||
{ | ||
domain: 'att.net', | ||
display_name: 'AT&T', | ||
region: 'UnitedStates', | ||
created_at: '2023-01-04T17:42:30.576Z', | ||
updated_at: '2023-02-17T17:20:20.664Z' | ||
}, | ||
{ | ||
domain: 'comcast.net', | ||
display_name: 'Comcast / Xfinity', | ||
region: 'United States', | ||
created_at: '2023-02-16T20:24:10.789Z', | ||
updated_at: '2023-02-16T20:24:10.789Z' | ||
} | ||
]; | ||
api.post('/v4/inbox/tests').reply(200, { | ||
result_id: 'test_result_id', | ||
links: { | ||
results: 'test_results' | ||
} | ||
}); | ||
|
||
const runTestResponse = await client.runTest({ | ||
from: 'from', | ||
subject: 'subject', | ||
provider_filter: ['test'], | ||
html: 'some html', | ||
}); | ||
runTestResponse.should.eql({ | ||
result_id: 'test_result_id', | ||
links: { | ||
results: 'test_results' | ||
}, | ||
status: 200 | ||
}); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import formData from 'form-data'; | ||
|
||
import nock from 'nock'; | ||
import Request from '../lib/Classes/common/Request'; | ||
|
||
import { InputFormData, RequestOptions } from '../lib/Types/Common'; | ||
|
||
import InboxPlacementsProvidersClient from '../lib/Classes/InboxPlacements/providers/InboxPlacementsProviders'; | ||
import { IInboxPlacementsProvidersClient } from '../lib/Interfaces/InboxPlacements/providers/InboxPlacementsProviders'; | ||
|
||
// TODO: fix types | ||
describe('Inbox Placements Providers', () => { | ||
let client: IInboxPlacementsProvidersClient; | ||
let api: nock.Scope; | ||
|
||
beforeEach(() => { | ||
const reqObject = new Request({ url: 'https://api.mailgun.net' } as RequestOptions, formData as InputFormData); | ||
client = new InboxPlacementsProvidersClient(reqObject); | ||
api = nock('https://api.mailgun.net'); | ||
}); | ||
|
||
afterEach(() => { | ||
api.done(); | ||
}); | ||
|
||
describe('list', () => { | ||
it('fetches inbox placements providers lists', async () => { | ||
const providers = [ | ||
{ | ||
domain: 'aol.com', | ||
display_name: 'AOL', | ||
region: 'Global', | ||
created_at: '2023-01-04T17:40:03.400Z', | ||
updated_at: '2023-02-17T17:20:12.172Z' | ||
}, | ||
{ | ||
domain: 'att.net', | ||
display_name: 'AT&T', | ||
region: 'UnitedStates', | ||
created_at: '2023-01-04T17:42:30.576Z', | ||
updated_at: '2023-02-17T17:20:20.664Z' | ||
}, | ||
{ | ||
domain: 'comcast.net', | ||
display_name: 'Comcast / Xfinity', | ||
region: 'United States', | ||
created_at: '2023-02-16T20:24:10.789Z', | ||
updated_at: '2023-02-16T20:24:10.789Z' | ||
} | ||
]; | ||
api.get('/v4/inbox/providers').reply(200, { | ||
items: providers | ||
}); | ||
|
||
const IPProviders = await client.list(); | ||
IPProviders.should.be.an('object').to.have.property('items'); | ||
IPProviders.should.be.an('object').to.have.property('status'); | ||
IPProviders.status.should.be.equal(200); | ||
|
||
IPProviders.items.should.be.an('array').to.have.property('length').to.equal(3); | ||
|
||
const expectedProviders = providers.map((provider) => ({ | ||
...provider, | ||
created_at: new Date(provider.created_at), | ||
updated_at: new Date(provider.updated_at) | ||
})); | ||
IPProviders.items.should.eql(expectedProviders); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.