@@ -5,18 +5,21 @@ import Sinon from 'sinon';
55const modelsMock = {
66 Users : {
77 findUsersByUsernames : ( usernames : string [ ] ) => ( {
8- toArray : async ( ) => usernames . map ( username => {
9- if ( username === 'user_valid' ) {
10- return { _id : '1' , username : 'user_valid' , emails : [ { address : 'valid@example.com' } ] } ;
11- }
12- if ( username === 'user_empty_emails' ) {
13- return { _id : '2' , username : 'user_empty_emails' , emails : [ ] } ;
14- }
15- if ( username === 'user_no_emails' ) {
16- return { _id : '3' , username : 'user_no_emails' } ; // undefined emails array
17- }
18- return null ;
19- } ) . filter ( Boolean ) ,
8+ toArray : async ( ) =>
9+ usernames
10+ . map ( ( username ) => {
11+ if ( username === 'user_valid' ) {
12+ return { _id : '1' , username : 'user_valid' , emails : [ { address : 'valid@example.com' } ] } ;
13+ }
14+ if ( username === 'user_empty_emails' ) {
15+ return { _id : '2' , username : 'user_empty_emails' , emails : [ ] } ;
16+ }
17+ if ( username === 'user_no_emails' ) {
18+ return { _id : '3' , username : 'user_no_emails' } ; // undefined emails array
19+ }
20+ return null ;
21+ } )
22+ . filter ( Boolean ) ,
2023 } ) ,
2124 } ,
2225 Messages : {
@@ -31,9 +34,15 @@ const mailerMock = {
3134 checkAddressFormat : ( ) => true ,
3235} ;
3336
34- const { sendViaEmail } = proxyquire . noCallThru ( ) . load ( './sendViaEmail.ts' , {
37+ const mockMoment = function ( ) {
38+ return {
39+ locale : ( ) => ( { format : ( ) => '12:00' } ) ,
40+ } ;
41+ } ;
42+
43+ const { sendViaEmail } = proxyquire . load ( './sendViaEmail.ts' , {
3544 '@rocket.chat/models' : modelsMock ,
36- '../../../app/mailer/server/api' : mailerMock ,
45+ '../../../app/mailer/server/api' : { Mailer : mailerMock } ,
3746 '../../../app/settings/server' : {
3847 settings : {
3948 get : ( ) => 'noreply@rocketchat.test' ,
0 commit comments