@@ -168,7 +168,7 @@ describe('Model/MarketingPreferencesModel', () => {
168168 transSource : 'giftaid-sportrelief' ,
169169 transSourceUrl : 'https://giftaid.sportrelief.com/' ,
170170 transType : 'prefs' ,
171- permissionEmail : 0 ,
171+ permissionEmail : 1 ,
172172 permissionPost : 0 ,
173173 permissionPhone : 0 ,
174174 permissionSMS : 0 ,
@@ -279,6 +279,47 @@ describe('Model/MarketingPreferencesModel', () => {
279279 } ) ;
280280
281281
282+ describe ( 'Ensure validation passes when email permission is NO' , ( ) => {
283+ const mockedData = {
284+ firstname : 'Kelvin' ,
285+ lastname : 'James' ,
286+ phone : '0208 254 3062' ,
287+ mobile : '07425253522' ,
288+ address1 : 'COMIC RELIEF' ,
289+ address2 : 'CAMELFORD HOUSE 87-90' ,
290+ address3 : 'ALBERT EMBANKMENT' ,
291+ town : 'LONDON' ,
292+ postcode : 'SE1 7TP' ,
293+ country : 'GB' ,
294+ campaign : 'RND19' ,
295+ transactionId : 'AN129MNDJDJ' ,
296+ transSource : 'RND19_GiftAid' ,
297+ transSourceUrl : 'https://giftaid.sportrelief.com/' ,
298+ transType : 'prefs' ,
299+ confirm : 1 ,
300+ permissionEmail : 0 ,
301+ permissionPost : null ,
302+ permissionPhone : null ,
303+ permissionSMS : null ,
304+ timestamp : '1562165588' ,
305+ } ;
306+
307+ const model = new MarketingPreferencesModel ( mockedData ) ;
308+
309+ it ( 'should validate the model' , ( done ) => {
310+ model . validate ( )
311+ . then ( ( ) => {
312+ expect ( true ) . to . eql ( true ) ;
313+ done ( ) ;
314+ } )
315+ . catch ( ( error ) => {
316+ console . log ( 'Error: ' , error ) ;
317+ expect ( true ) . to . eql ( false ) ;
318+ done ( ) ;
319+ } ) ;
320+ } ) ;
321+ } ) ;
322+
282323 describe ( 'Ensure generating of timestamp when not set' , ( ) => {
283324
284325 const mockedData = {
0 commit comments