<commit_before>var st = require('../st.js')
var test = require('tap').test
var util = require('util')
var path = require('path')

var opts = util._extend({
  autoindex: true,
  path: path.resolve(__dirname, './fixtures'),
  url: '/',
  passthrough: true
}, global.options || {})

var mount = st(opts)

test('call next() if passthrough is set', function (t) {
  var req = { url: '/index.html' }
  var res = {}
  t.plan(1)
  function next() {
    t.ok(true, "next called")
  }
  mount(req, res, next)
})

opts = util._extend({
  autoindex: true,
  path: path.resolve(__dirname, './fixtures'),
  url: '/'
}, global.options || {})

mount = st(opts)

test('return error if passthrough is not set', function (t) {
  var req = { url: '/doesnotexist.txt' }
  var res = {
    error: function () {
      t.ok(true, "error used")
      t.end()
    }
  }
  t.plan(1)
  mount(req, res, function () {
    t.end()
  })
})
<commit_msg>fix passthrough tests<commit_after>var st = require('../st.js')
var test = require('tap').test
var util = require('util')
var path = require('path')

var opts = util._extend({
  autoindex: true,
  path: path.resolve(__dirname, './fixtures'),
  url: '/',
  passthrough: true
}, global.options || {})

var mount = st(opts)

test('call next() if passthrough is set', function (t) {
  var req = { method: 'GET', url: '/doesnotexist.txt', headers: {} }
  var res = {
    error: function () {
      t.end()
    },
    setHeader: function () {},
    end: function () {}
  }
  t.plan(1)
  function next() {
    t.ok(true, "next called")
    t.end()
  }
  mount(req, res, next)
})

var opts2 = util._extend({
  autoindex: true,
  path: path.resolve(__dirname, './fixtures'),
  url: '/'
}, global.options || {})
mount2 = st(opts2)

test('return error if passthrough is not set', function (t) {
  var req = { method: 'GET', url: '/doesnotexist.txt', headers: {} }
  var res = {
    setHeader: function () {},
    error: function () {
      t.ok(true, "error used")
      t.end()
    },
    end: function () {}
  }
  t.plan(1)
  mount2(req, res, function () {
    t.end()
  })
})

{'fraction_non_alphanumeric': 0.19597508385241974, 'fraction_numerical': 0.003833253473885961, 'mean_word_length': 2.9923518164435947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1833620', 'n_tokens_mistral': 761, 'n_tokens_neox': 762, 'n_words': 195}