How to use the emailjs.__spy function in emailjs

To help you get started, we’ve selected a few emailjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nickbalestra / zero / __tests__ / email.js View on Github external
test('deliver.send()', async () => {
  const deliver = email(smtpConfig);

  const token = '123.123.123';
  const user = { name: 'John', email: 'john@doe.com' };
  const req = { hostname: 'a-domain.com', protocol: 'http' };
  await deliver.send(user, token, req);

  expect(emailjs.__spy.connect).toHaveBeenCalledWith({
    host: 'smtp.domain.com',
    password: 'secure',
    port: '465',
    ssl: true,
    user: 'user@domain.com'
  });
  expect(emailjs.__spy.send.mock.calls[0][0]).toEqual({
    from: 'from@domain.com',
    subject: 'Token for a-domain.com!',
    text:
      'Hello!\nAccess your account here: http://a-domain.com/?token=123.123.123',
    to: 'john@doe.com'
  });
});
github nickbalestra / zero / __tests__ / email.js View on Github external
...smtpConfig
  });

  const token = '123.123.123';
  const user = { name: 'John', email: 'john@doe.com' };
  const req = { hostname: 'a-domain.com', protocol: 'http' };
  await deliver.send(user, token, req);

  expect(emailjs.__spy.connect).toHaveBeenCalledWith({
    host: 'smtp.domain.com',
    password: 'secure',
    port: '465',
    ssl: true,
    user: 'user@domain.com'
  });
  expect(emailjs.__spy.send.mock.calls[0][0]).toEqual({
    from: 'from@domain.com',
    subject: 'Token for a-domain.com!',
    text:
      'Hello!\nAccess your account here: http://a-domain.com/?acceptToken=123.123.123',
    to: 'john@doe.com'
  });
  expect(deliver.tokenField).toBe('acceptToken');
});

emailjs

send text/html emails and attachments (files, streams and strings) from node.js to any smtp server

MIT
Latest version published 1 year ago

Package Health Score

59 / 100
Full package analysis