diff --git a/apps/common/behaviours/email.js b/apps/common/behaviours/email.js index f2725ee1..2c145d75 100644 --- a/apps/common/behaviours/email.js +++ b/apps/common/behaviours/email.js @@ -1,6 +1,7 @@ /* eslint-disable consistent-return */ 'use strict'; +const moment = require('moment'); const _ = require('underscore'); const StatsD = require('hot-shots'); const client = new StatsD(); @@ -63,6 +64,8 @@ module.exports = superclass => class Emailer extends superclass { saveValues(req, res, callback) { super.saveValues(req, res, () => { const data = _.pick(req.sessionModel.toJSON(), _.identity); + data['date-lost'] = moment(data['date-lost']).format('DD MMMM YYYY'); + data['date-of-birth'] = moment(data['date-of-birth']).format('DD MMMM YYYY'); const service = serviceMap[req.baseUrl] && serviceMap[req.baseUrl](data); if (!service) { diff --git a/apps/lost-stolen/views/confirm.html b/apps/lost-stolen/views/confirm.html index 3b7bc0b7..fffdd4b6 100644 --- a/apps/lost-stolen/views/confirm.html +++ b/apps/lost-stolen/views/confirm.html @@ -35,7 +35,7 @@ - + @@ -45,7 +45,7 @@ - + diff --git a/test/_unit/apps/common/behaviours/email.spec.js b/test/_unit/apps/common/behaviours/email.spec.js index 4bec8517..423b0b4f 100644 --- a/test/_unit/apps/common/behaviours/email.spec.js +++ b/test/_unit/apps/common/behaviours/email.spec.js @@ -2,6 +2,7 @@ const { expect } = require('chai'); const Controller = require('hof').controller; +const moment = require('moment'); describe('apps/common/controllers/confirm', () => { describe('.saveValues()', () => { @@ -28,7 +29,9 @@ describe('apps/common/controllers/confirm', () => { req = reqres.req({ session: { - foo: 'bar' + foo: 'bar', + 'date-lost': '01 November 2022', + 'date-of-birth': '01 November 2022' } }); res = reqres.res(); @@ -42,7 +45,11 @@ describe('apps/common/controllers/confirm', () => { req.baseUrl = '/collection'; controller.saveValues(req, res, err => { expect(err).not.to.be.ok; - constructorStub.should.have.been.calledWith({ foo: 'bar' }); + const data = req.sessionModel.attributes; + constructorStub.should.have.been.calledWith({ + foo: 'bar', + 'date-lost': moment(data['date-lost']).format('DD MMMM YYYY'), + 'date-of-birth': moment(data['date-of-birth']).format('DD MMMM YYYY')}); saveStub.should.have.been.called; }); });
{{#t}}pages.check-details.table.headers.date-lost{{/t}}{{values.date-lost}}{{#date}}{{values.date-lost}}{{/date}} {{#t}}buttons.change.date-lost{{/t}}
{{#t}}pages.check-details.table.headers.date-of-birth{{/t}}{{values.date-of-birth}}{{#date}}{{values.date-of-birth}}{{/date}} {{#t}}buttons.change.date-of-birth{{/t}}