Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('filters events with wrong order state', async () => {
eventBus.publish(new OrderStateTransitionEvent('AddingItems', 'ArrangingPayment', ctx, order));
await pause();
expect(onSend).not.toHaveBeenCalled();
eventBus.publish(new OrderStateTransitionEvent('AddingItems', 'Cancelled', ctx, order));
await pause();
expect(onSend).not.toHaveBeenCalled();
eventBus.publish(new OrderStateTransitionEvent('AddingItems', 'PaymentAuthorized', ctx, order));
await pause();
expect(onSend).not.toHaveBeenCalled();
eventBus.publish(new OrderStateTransitionEvent('ArrangingPayment', 'PaymentSettled', ctx, order));
await pause();
expect(onSend).toHaveBeenCalledTimes(1);
});
it('sets the subject', async () => {
eventBus.publish(new OrderStateTransitionEvent('ArrangingPayment', 'PaymentSettled', ctx, order));
await pause();
expect(onSend.mock.calls[0][0].subject).toBe(`Order confirmation for #${order.code}`);
});
});
it('filters events with wrong order state', async () => {
eventBus.publish(new OrderStateTransitionEvent('AddingItems', 'ArrangingPayment', ctx, order));
await pause();
expect(onSend).not.toHaveBeenCalled();
eventBus.publish(new OrderStateTransitionEvent('AddingItems', 'Cancelled', ctx, order));
await pause();
expect(onSend).not.toHaveBeenCalled();
eventBus.publish(new OrderStateTransitionEvent('AddingItems', 'PaymentAuthorized', ctx, order));
await pause();
expect(onSend).not.toHaveBeenCalled();
eventBus.publish(new OrderStateTransitionEvent('ArrangingPayment', 'PaymentSettled', ctx, order));
await pause();
expect(onSend).toHaveBeenCalledTimes(1);
});
it('filters events with wrong order state', async () => {
eventBus.publish(new OrderStateTransitionEvent('AddingItems', 'ArrangingPayment', ctx, order));
await pause();
expect(onSend).not.toHaveBeenCalled();
eventBus.publish(new OrderStateTransitionEvent('AddingItems', 'Cancelled', ctx, order));
await pause();
expect(onSend).not.toHaveBeenCalled();
eventBus.publish(new OrderStateTransitionEvent('AddingItems', 'PaymentAuthorized', ctx, order));
await pause();
expect(onSend).not.toHaveBeenCalled();
eventBus.publish(new OrderStateTransitionEvent('ArrangingPayment', 'PaymentSettled', ctx, order));
await pause();
expect(onSend).toHaveBeenCalledTimes(1);
});
import {
AccountRegistrationEvent,
Customer,
IdentifierChangeRequestEvent,
Order,
OrderItem,
OrderLine,
OrderStateTransitionEvent,
PasswordResetEvent,
ProductVariant,
User,
} from '@vendure/core';
export const mockOrderStateTransitionEvent = new OrderStateTransitionEvent(
'ArrangingPayment',
'PaymentSettled',
{} as any,
new Order({
id: '6',
createdAt: '2018-10-31T15:18:29.261Z',
updatedAt: '2018-10-31T15:24:17.000Z',
code: 'T3EPGJKTVZPBD6Z9',
state: 'ArrangingPayment',
active: true,
customer: new Customer({
id: '3',
firstName: 'Test',
lastName: 'Customer',
emailAddress: 'test@test.com',
}),