@@ -61,6 +61,40 @@ function mightBeAComplaint(messageInfo) {
6161}
6262
6363test ( 'ARF complaint detection tests' , async t => {
64+ await t . test ( 'handles missing attachments gracefully' , async ( ) => {
65+ // Test with undefined attachments
66+ const messageInfoUndefined = {
67+ from : { address : 'test@example.com' } ,
68+ subject : 'Test'
69+ } ;
70+ const reportUndefined = await arfDetect ( messageInfoUndefined ) ;
71+ assert . ok ( reportUndefined ) ;
72+ assert . deepStrictEqual ( reportUndefined . arf , { } ) ;
73+ assert . deepStrictEqual ( reportUndefined . headers , { } ) ;
74+
75+ // Test with null attachments
76+ const messageInfoNull = {
77+ from : { address : 'test@example.com' } ,
78+ subject : 'Test' ,
79+ attachments : null
80+ } ;
81+ const reportNull = await arfDetect ( messageInfoNull ) ;
82+ assert . ok ( reportNull ) ;
83+ assert . deepStrictEqual ( reportNull . arf , { } ) ;
84+ assert . deepStrictEqual ( reportNull . headers , { } ) ;
85+
86+ // Test with empty attachments array
87+ const messageInfoEmpty = {
88+ from : { address : 'test@example.com' } ,
89+ subject : 'Test' ,
90+ attachments : [ ]
91+ } ;
92+ const reportEmpty = await arfDetect ( messageInfoEmpty ) ;
93+ assert . ok ( reportEmpty ) ;
94+ assert . deepStrictEqual ( reportEmpty . arf , { } ) ;
95+ assert . deepStrictEqual ( reportEmpty . headers , { } ) ;
96+ } ) ;
97+
6498 await t . test ( 'Yahoo ARF abuse report' , async ( ) => {
6599 const messageInfo = await parseForArfDetect ( path ( 'yahoo.eml' ) ) ;
66100 const report = await arfDetect ( messageInfo ) ;
0 commit comments