Make subject optional too

This commit is contained in:
Hongbo Wu
2023-02-01 13:53:27 +08:00
parent ac6f5b497c
commit dd6c8cf6dc
2 changed files with 16 additions and 1 deletions

View File

@ -36,7 +36,7 @@ interface EmailMessage {
}
function isEmailMessage(data: any): data is EmailMessage {
return 'from' in data && 'to' in data && 'subject' in data
return 'from' in data && 'to' in data
}
const logger = buildLogger('app.dispatch')

View File

@ -163,5 +163,20 @@ describe('Emails Router', () => {
expect(res.body.id).not.to.be.undefined
})
it('saves the email if subject is empty', async () => {
const data = {
from,
to: newsletterEmail,
html,
}
const res = await request
.post(url)
.set('Authorization', `${authToken}`)
.send(data)
.expect(200)
expect(res.body.id).not.to.be.undefined
})
})
})