|
| 1 | +import type { CreateEmailOptions } from '../../emails/interfaces/create-email-options.interface'; |
| 2 | +import { parseEmailToApiOptions } from './parse-email-to-api-options'; |
| 3 | + |
| 4 | +describe('parseEmailToApiOptions', () => { |
| 5 | + it('should handle minimal email with only required fields', () => { |
| 6 | + const emailPayload: CreateEmailOptions = { |
| 7 | + |
| 8 | + |
| 9 | + subject: 'Hey, there!', |
| 10 | + html: '<h1>Hey, there!</h1>', |
| 11 | + }; |
| 12 | + |
| 13 | + const apiOptions = parseEmailToApiOptions(emailPayload); |
| 14 | + |
| 15 | + expect(apiOptions).toEqual({ |
| 16 | + |
| 17 | + |
| 18 | + subject: 'Hey, there!', |
| 19 | + html: '<h1>Hey, there!</h1>', |
| 20 | + }); |
| 21 | + }); |
| 22 | + |
| 23 | + it('should properly parse camel case to snake case', () => { |
| 24 | + const emailPayload: CreateEmailOptions = { |
| 25 | + |
| 26 | + |
| 27 | + subject: 'Hey, there!', |
| 28 | + html: '<h1>Hey, there!</h1>', |
| 29 | + |
| 30 | + scheduledAt: 'in 1 min', |
| 31 | + }; |
| 32 | + |
| 33 | + const apiOptions = parseEmailToApiOptions(emailPayload); |
| 34 | + |
| 35 | + expect(apiOptions).toEqual({ |
| 36 | + |
| 37 | + |
| 38 | + subject: 'Hey, there!', |
| 39 | + html: '<h1>Hey, there!</h1>', |
| 40 | + |
| 41 | + scheduled_at: 'in 1 min', |
| 42 | + }); |
| 43 | + }); |
| 44 | +}); |
0 commit comments