Skip to content

Commit

Permalink
fix(cypress): fix assertions "include" that does not really check if …
Browse files Browse the repository at this point in the history
…value includes another value (#6)
  • Loading branch information
RomulusED69 authored May 28, 2020
1 parent ff9d525 commit 2fdbe52
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;
use Symfony\Component\Routing\Annotation\Route;

Expand All @@ -19,8 +20,8 @@ class EmailController extends AbstractController
public function sendBasicEmail(Request $request, MailerInterface $mailer): Response
{
$email = (new Email())
->from('[email protected]')
->to('[email protected]')
->from(Address::fromString($request->request->get('from', '[email protected]')))
->to(Address::fromString($request->request->get('to', '[email protected]')))
->subject($request->request->get('subject', 'Email sent from a Symfony application!'))
->text($request->request->get('text', 'Hello world!'))
->html($request->request->get('html', '<b>Hello world!</b>'))
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Cypress/support/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ function assertions(_chai, utils) {
}

this.assert(
headerFiltered && headerFiltered.body === value,
headerFiltered && headerFiltered.body.includes(value),
messageSuccess,
messageFailure,
value, // expected
Expand Down
6 changes: 4 additions & 2 deletions tests/Bridge/Cypress/specs/email.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
function sendEmail({ subject, attachments, text, html } = {}) {
function sendEmail({ subject, from, to, attachments, text, html } = {}) {
cy.request({
method: 'POST',
url: '/send-basic-email',
form: true,
body: {
subject,
from,
to,
attachments,
text,
html,
Expand Down Expand Up @@ -100,7 +102,7 @@ describe('I test an email', function () {
});

specify('I can test email addresses', function () {
sendEmail({ subject: 'Hello world!' });
sendEmail({ subject: 'Hello world!', to: 'John <[email protected]>' });

cy.getMessageEvents().then((messageEvents) => {
expect(messageEvents.events[0]).to.have.address('From').eq('[email protected]');
Expand Down

0 comments on commit 2fdbe52

Please sign in to comment.