<commit_before>'use strict'

var Assert = require('assert')
var Lab = require('lab')
var Common = require('../lib/common')

var lab = exports.lab = Lab.script()
var describe = lab.describe
var it = lab.it
var assert = Assert

describe('hapi adapter', () => {
  it('can autostart' (done) => {
    done()
  })

  it('can accept a premade instance', (done) => {
    done()
  })

  it('exports correctly', (done) => {
    done()
  })

  it('passes settings correctly', (done) => {
    done()
  })

  it('populates msg.args correctly', (done) => {

  }
})<commit_msg>added test. It is broken when running with lab... for now<commit_after>'use strict'

let expect = require('code').expect
let Lab = require('lab')
let Hapi = require('hapi')
let Seneca = require('seneca')
let Web = require('../')
let request = require('request')

let lab = exports.lab = Lab.script()

let describe = lab.describe
let it = lab.it
let beforeEach = lab.beforeEach
let afterEach = lab.afterEach

let defaultRoutes = [
  {
    prefix: '/api',
    pin: 'role:test,cmd:*',
    map: {
      ping: true
    }
  }
]


var server = new Hapi.Server()
server.connection({port: 4000})

var seneca = Seneca()
  .use(function plugin () {
    this.add('role:test,cmd:ping', (msg, reply) => {
      reply(null, {response: 'pong!'})
    })
  })
  .use(Web, {adapter: 'hapi', context: server})
  .ready(() => {
    seneca.act('role:web', {routes: defaultRoutes}, (err, reply) => {
      server.start((err) => {
        console.log(server.table())
        console.log('server started on: ' + server.info.uri)
      })
    })
  })


lab.experiment('hapi', () => {
  
  lab.test('can autostart', (done) => {
  
    request('http://127.0.0.1:4000/api/ping', (error, response, body) => {
        expect(error).to.be.undefined
        done()
    })
    
  })
})
{'fraction_non_alphanumeric': 0.19139547710976282, 'fraction_numerical': 0.007722007722007722, 'mean_word_length': 3.031111111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '5241452', 'n_tokens_mistral': 642, 'n_tokens_neox': 622, 'n_words': 149}