contact-form.ts 762 B

12345678910111213141516171819202122232425262728293031
  1. import * as request from 'supertest'
  2. import { ContactForm } from '../../models/server'
  3. import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
  4. function sendContactForm (options: {
  5. url: string
  6. fromEmail: string
  7. fromName: string
  8. subject: string
  9. body: string
  10. expectedStatus?: number
  11. }) {
  12. const path = '/api/v1/server/contact'
  13. const body: ContactForm = {
  14. fromEmail: options.fromEmail,
  15. fromName: options.fromName,
  16. subject: options.subject,
  17. body: options.body
  18. }
  19. return request(options.url)
  20. .post(path)
  21. .send(body)
  22. .expect(options.expectedStatus || HttpStatusCode.NO_CONTENT_204)
  23. }
  24. // ---------------------------------------------------------------------------
  25. export {
  26. sendContactForm
  27. }