aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/server/contact-form.ts
blob: 80394cf994849792ed10780f3c1f62d3f495e19a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import * as request from 'supertest'
import { ContactForm } from '../../models/server'

function sendContactForm (options: {
  url: string,
  fromEmail: string,
  fromName: string,
  body: string,
  expectedStatus?: number
}) {
  const path = '/api/v1/server/contact'

  const body: ContactForm = {
    fromEmail: options.fromEmail,
    fromName: options.fromName,
    body: options.body
  }
  return request(options.url)
    .post(path)
    .send(body)
    .expect(options.expectedStatus || 204)
}

// ---------------------------------------------------------------------------

export {
  sendContactForm
}