contact-form.ts 658 B

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