Skip to content

Commit

Permalink
Add sentTo search criterion
Browse files Browse the repository at this point in the history
  • Loading branch information
jm-mailosaur committed Oct 19, 2020
1 parent 5f163cf commit 4c34395
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/mailosaurCommands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ export interface MessageListResult {
* @class
* Initializes a new instance of the SearchCriteria class.
* @constructor
* @member {string} [sentFrom] The full email address from which the target email
* was sent.
* @member {string} [sentTo] The full email address to which the target email
* was sent.
* @member {string} [subject] The value to seek within the target email's
Expand All @@ -235,6 +237,7 @@ export interface MessageListResult {
*/
export interface SearchCriteria {
sentFrom?: string;
sentTo?: string;
subject?: string;
body?: string;
Expand Down Expand Up @@ -378,6 +381,11 @@ declare namespace Cypress {
body: string
): Cypress.Chainable<MessageListResult>;

mailosaurGetMessagesBySentFrom(
serverId: string,
sentFrom: string
): Cypress.Chainable<MessageListResult>;

mailosaurGetMessagesBySentTo(
serverId: string,
sentTo: string
Expand Down
5 changes: 5 additions & 0 deletions src/mailosaurCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class MailosaurCommands {
'mailosaurSearchMessages',
'mailosaurGetMessagesBySubject',
'mailosaurGetMessagesByBody',
'mailosaurGetMessagesBySentFrom',
'mailosaurGetMessagesBySentTo',
'mailosaurDeleteMessage',
'mailosaurDeleteAllMessages',
Expand Down Expand Up @@ -159,6 +160,10 @@ class MailosaurCommands {
return cy.mailosaurSearchMessages(serverId, { body });
}

mailosaurGetMessagesBySentFrom(serverId, sentFrom) {
return cy.mailosaurSearchMessages(serverId, { sentFrom });
}

mailosaurGetMessagesBySentTo(serverId, sentTo) {
return cy.mailosaurSearchMessages(serverId, { sentTo });
}
Expand Down
26 changes: 26 additions & 0 deletions test/react-app/cypress/integration/messages.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ describe('Mailosaur message commands', () => {
});
});

describe('.mailosaurGetMessagesBySentFrom', () => {
it('should return matching results', (done) => {
const targetEmail = emails[1];
cy.mailosaurGetMessagesBySentFrom(server, targetEmail.from[0].email).then((result) => {
expect(result.items).to.have.lengthOf(5);
expect(result.items[0].from[0].email).to.equal(targetEmail.from[0].email);
expect(result.items[0].subject).to.equal(targetEmail.subject);
done();
});
});
});

describe('.mailosaurGetMessagesBySentTo', () => {
it('should return matching results', (done) => {
const targetEmail = emails[1];
Expand All @@ -187,6 +199,20 @@ describe('Mailosaur message commands', () => {
});

describe('.mailosaurSearchMessages', () => {
describe('by sentFrom', () => {
it('should return matching results', (done) => {
const targetEmail = emails[1];
cy.mailosaurSearchMessages(server, {
sentFrom: targetEmail.from[0].email
}).then((result) => {
expect(result.items).to.have.lengthOf(5);
expect(result.items[0].from[0].email).to.equal(targetEmail.from[0].email);
expect(result.items[0].subject).to.equal(targetEmail.subject);
done();
});
});
});

describe('by sentTo', () => {
it('should return matching results', (done) => {
const targetEmail = emails[1];
Expand Down

0 comments on commit 4c34395

Please sign in to comment.