<commit_before>const frisby = require('frisby')
var fs = require('fs')
var path = require('path')
var FormData = require('form-data')

const URL = 'http://localhost:3000'

// FIXME Adapt to solution of https://github.com/vlucas/frisby/issues/372
describe('/file-upload', function () {
  var file, form

  xit('POST file valid for client and API', function (done) {
    file = path.resolve(__dirname, '../files/validSizeAndTypeForClient.pdf')
    form = new FormData()
    form.append('file', fs.createReadStream(file))

    frisby.post(URL + '/file-upload', { headers: form.getHeaders(), body: form })
      .expect('status', 204)
      .done(done)
  })

  xit('POST file too large for client validation but valid for API', function (done) {
    file = path.resolve(__dirname, '../files/invalidSizeForClient.pdf')
    form = new FormData()
    form.append('file', fs.createReadStream(file))

    frisby.post(URL + '/file-upload', { headers: form.getHeaders(), body: form })
      .expect('status', 204)
      .done(done)
  })

  xit('POST file with illegal type for client validation but valid for API', function (done) {
    file = path.resolve(__dirname, '../files/invalidTypeForClient.exe')
    form = new FormData()
    form.append('file', fs.createReadStream(file))

    frisby.post(URL + '/file-upload', { headers: form.getHeaders(), body: form })
      .expect('status', 204)
      .done(done)
  })

  xit('POST file too large for API', function (done) {
    file = path.resolve(__dirname, '../files/invalidSizeForServer.pdf')
    form = new FormData()
    form.append('file', fs.createReadStream(file))

    frisby.post(URL + '/file-upload', { headers: form.getHeaders(), body: form })
      .expect('status', 500)
      .done(done)
  })
})<commit_msg>Enable file upload tests (see https://github.com/vlucas/frisby/pull/374)<commit_after>const frisby = require('frisby')
var fs = require('fs')
var path = require('path')
var FormData = require('form-data')

const URL = 'http://localhost:3000'

// FIXME Adapt to solution of https://github.com/vlucas/frisby/issues/372
describe('/file-upload', function () {
  var file, form

  it('POST file valid for client and API', function (done) {
    file = path.resolve(__dirname, '../files/validSizeAndTypeForClient.pdf')
    form = new FormData()
    form.append('file', fs.createReadStream(file))

    frisby.post(URL + '/file-upload', { headers: form.getHeaders(), body: form })
      .expect('status', 204)
      .done(done)
  })

  it('POST file too large for client validation but valid for API', function (done) {
    file = path.resolve(__dirname, '../files/invalidSizeForClient.pdf')
    form = new FormData()
    form.append('file', fs.createReadStream(file))

    frisby.post(URL + '/file-upload', { headers: form.getHeaders(), body: form })
      .expect('status', 204)
      .done(done)
  })

  it('POST file with illegal type for client validation but valid for API', function (done) {
    file = path.resolve(__dirname, '../files/invalidTypeForClient.exe')
    form = new FormData()
    form.append('file', fs.createReadStream(file))

    frisby.post(URL + '/file-upload', { headers: form.getHeaders(), body: form })
      .expect('status', 204)
      .done(done)
  })

  it('POST file too large for API', function (done) {
    file = path.resolve(__dirname, '../files/invalidSizeForServer.pdf')
    form = new FormData()
    form.append('file', fs.createReadStream(file))

    frisby.post(URL + '/file-upload', { headers: form.getHeaders(), body: form })
      .expect('status', 500)
      .done(done)
  })
})
{'fraction_non_alphanumeric': 0.16447552447552446, 'fraction_numerical': 0.01146853146853147, 'mean_word_length': 3.5787451984635084, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7558865', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1102, 'n_words': 281}