Skip to content
This repository has been archived by the owner on May 28, 2018. It is now read-only.

Commit

Permalink
Test number of emails sent on application sending and saving actions
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrohee committed Jul 26, 2017
1 parent 87db7d4 commit 8b0f5e4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 17 additions & 2 deletions server/api/application/test/application.api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ const applicationData = require('./application.seed')
const applicationOtherData = require('./application.other.seed')
const expect = require('expect')
const qs = require('qs')
const nodemailerMock = require('nodemailer-mock')

const authHelper = require('../../lib/testUtils/authHelper')

describe('api: application', () => {
let app

before(() => {
app = new Server({ isTest: true }).getApp()
app = new Server({ isTest: true, mailer: nodemailerMock }).getApp()
})

afterEach(() => {
nodemailerMock.mock.reset()
})

describe('When requesting /api/application/ping', () => {
Expand Down Expand Up @@ -127,6 +132,8 @@ describe('api: application', () => {
return done(err)
}
expect(res.body).toContain(validApplication)
const sentMail = nodemailerMock.mock.sentMail()
expect(sentMail.length).toBe(1)
done()
})
})
Expand Down Expand Up @@ -235,7 +242,15 @@ describe('api: application', () => {
it('should return a 200', (done) => {
supertest(app)
.put('/api/application/9c9d6a6b832effc406059b15/send')
.expect(200, done)
.expect(200)
.end((err) => {
if (err) {
return done(err)
}
const sentMail = nodemailerMock.mock.sentMail()
expect(sentMail.length).toBe(3)
return done()
})
})
})

Expand Down
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"coveralls": "2.11.9",
"eslint": "3.0.0",
"expect": "1.20.2",
"nodemailer-mock": "1.3.3",
"npm-run-all": "2.3.0",
"qs": "6.5.0",
"supertest": "1.2.0"
Expand Down

0 comments on commit 8b0f5e4

Please sign in to comment.