1
0
Эх сурвалжийг харах

test(email-plugin): Add test to verify BCC functionality with orderConfirmationHandler (#3836)

John Gerwin De las Alas 3 сар өмнө
parent
commit
c8b33874b7

+ 18 - 0
packages/email-plugin/src/plugin.spec.ts

@@ -773,6 +773,24 @@ describe('EmailPlugin', () => {
 
             expect(onSend.mock.calls[0][0].subject).toBe(`Order confirmation for #${order.code as string}`);
         });
+
+        it('supports BCC address', async () => {
+            onSend.mockClear();
+            const bccHandler = orderConfirmationHandler.setOptionalAddressFields(event => ({
+                bcc: 'bcc@example.com',
+            }));
+
+            const initResult = await initPluginWithHandlers([bccHandler], {
+                templateLoader: new FileBasedTemplateLoader(path.join(__dirname, '../templates')),
+            });
+
+            await eventBus.publish(
+                new OrderStateTransitionEvent('ArrangingPayment', 'PaymentSettled', ctx, order),
+            );
+            await pause();
+
+            expect(onSend.mock.calls[0][0].bcc).toBe('bcc@example.com');
+        });
     });
 
     describe('error handling', () => {