<commit_before>{puts,inspect} = require 'sys'
joinPath = require('path').join
assert = require 'assert'
vows = require 'vows'

vh = require '../http-helper'

testPort = 50666

basicRequest = vh.buildRequest "localhost:#{testPort}"

requestUploadPhoto = vh.buildRequest "localhost:#{testPort}",
  headers: {'Content-Type': 'image/jpeg'}
  bodyFromFile: "./fixtures/awesome-cat-jacket.jpg"

mimeBoundary = '||BOUNDARY||'

requestUploadMultipart = vh.buildRequest "localhost:#{testPort}",
  headers: {'Content-Type': "multipart/form-data; boundary=#{mimeBoundary}"}
  bodyFromFile: "./fixtures/multipart-form-upload"

vows.describe('Vows HTTP macros')
  
  .addBatch
    'start test server':
      topic: -> testServer.listen testPort, @callback
      'should have started': -> null

  .addBatch
    'GET  /': basicRequest.respondsWith 200
      'should say something': (res) -> assert.isTrue res.body.length > 0
    <commit_msg>slight refactor<commit_after>{puts,inspect} = require 'sys'
joinPath = require('path').join
assert = require 'assert'
vows = require 'vows'

vh = require '../http-helper'

testPort = 50666

basicRequest = vh.buildRequest "localhost:#{testPort}"

requestUploadPhoto = vh.buildRequest "localhost:#{testPort}",
  headers: {'Content-Type': 'image/jpeg'}
  bodyFromFile: "./fixtures/awesome-cat-jacket.jpg"

requestUploadMultipart = vh.buildRequest "localhost:#{testPort}",
  headers: {'Content-Type': "multipart/form-data; boundary=||BOUNDARY||"}
  bodyFromFile: "./fixtures/multipart-form-upload"

vows.describe('Vows HTTP macros')
  
  .addBatch
    'start test server':
      topic: -> testServer.listen testPort, @callback
      'should have started': -> null

  .addBatch
    'GET  /': basicRequest.respondsWith 200
      'should say something': (res) -> assert.isTrue res.body.length > 0
    
{'fraction_non_alphanumeric': 0.15274725274725276, 'fraction_numerical': 0.00989010989010989, 'mean_word_length': 4.419642857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, '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': '3802189', 'n_tokens_mistral': 611, 'n_tokens_neox': 588, 'n_words': 127}