File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,8 +11,9 @@ class EmailService {
1111 }
1212 this . mailer = nodemailer . createTransport ( settings )
1313 }
14- sendEmail ( email , callback ) {
15- this . mailer . sendEmail ( email , callback )
14+ sendMail ( email , callback ) {
15+ console . log ( this . mailer )
16+ this . mailer . sendMail ( email , callback )
1617 }
1718}
1819
Original file line number Diff line number Diff line change 4545 "negotiator" : " ^0.6.0" ,
4646 "node-forge" : " ^0.6.38" ,
4747 "node-uuid" : " ^1.4.3" ,
48+ "nodemailer" : " ^2.3.2" ,
4849 "nomnom" : " ^1.8.1" ,
4950 "rdflib" : " ^0.6.1" ,
5051 "request" : " ^2.72.0" ,
6061 "mocha" : " ^2.2.5" ,
6162 "nock" : " ^7.0.2" ,
6263 "rsvp" : " ^3.1.0" ,
64+ "sinon" : " ^1.17.4" ,
6365 "standard" : " ^6.0.4" ,
6466 "supertest" : " ^1.0.1"
6567 },
Original file line number Diff line number Diff line change 1+ const EmailService = require ( '../lib/email-service' )
2+ const sinon = require ( 'sinon' )
3+ const expect = require ( 'chai' ) . expect
4+
5+ describe ( 'Email Service' , function ( ) {
6+ let email , transport
7+
8+ beforeEach ( ( ) => {
9+ transport = {
10+ name : 'testsend' ,
11+ version : '1' ,
12+ send : function ( data , callback ) {
13+ callback ( ) ;
14+ } ,
15+ logger : false
16+ }
17+ email = new EmailService ( transport )
18+ } )
19+
20+ it ( 'should send emails' , ( done ) => {
21+ sinon . stub ( transport , 'send' ) . yields ( null , 'bep bop' )
22+
23+ email . sendMail ( {
24+ subject : 'test'
25+ } , function ( err , info ) {
26+ expect ( err ) . to . not . exist ;
27+ expect ( info ) . to . equal ( 'bep bop' )
28+ done ( )
29+ } )
30+ } )
31+ } )
You can’t perform that action at this time.
0 commit comments