import test from 'ava'
import request from 'supertest'
import app from '..'

test('/api/generate/resume -> it should generate a PDF', async t => {
  const data = {
    template: 1,
    profile: {
      fullName: 'Saad Quadri',
      email: 'saad@saadq.com',
      link: 'github.com/saadq'
    }
  }

  const response = await request(app.listen())
    .post('/api/generate/resume')
    .set('Accept', 'application/pdf')
    .set('Content-Type', 'application/json')
    .send(data)
    .expect('Content-Type', 'application/pdf')
    .expect(200)

  t.truthy(response)
  t.truthy(response.text)
})

test('/api/generate/source -> it should generate source code zip', async t => {
  const data = {
    template: 2,
    profile: {
      fullName: 'Saad Quadri',
      email: 'saad@saadq.com',
      link: 'github.com/saadq'
    }
  }

  const response = await request(app.listen())
    .post('/api/generate/source')
    .set('Accept', 'application/octet-stream')
    .set('Content-Type', 'application/json')
    .send(data)
    .expect('Content-Type', 'application/octet-stream')
    .expect(200)

  t.truthy(response)
})

@@ -585,16 +585,95 @@
 e.text)%0A
+  t.true(typeof response.text === 'string')%0A  t.true(response.text.length %3E 0)%0A
 %7D)%0A%0Atest
@@ -1185,11 +1185,78 @@
 sponse)%0A
+  t.truthy(response.body)%0A  t.true(Buffer.isBuffer(response.body))%0A
 %7D)%0A

update endpoint tests