/* eslint-env node, mocha */
const chai = require('chai')
const chaiHttp = require('chai-http')
const should = chai.should()
//const expect=chai.expect
const host = 'http://localhost:8080'
chai.use(chaiHttp)

//----------------------general----------------------------------
describe('test environment', () => {
  it('mocha is working', () => {
    let obj = null
    should.not.exist(obj)
  })
  it('server is running', (done) => {
    chai.request(host).get('/').end((err, res) => {
      res.should.have.status(200)
      done()
    })
  })
})


//----------------------static dynamic and rest requests---------
describe('requests', () => {
  var service = '/cars'
  it('index page', (done) => {
    chai.request(host).get('/index').end((err, res) => {
      res.should.have.status(200)
      done()
    })
  })
  it('rest get', (done) => {
    chai.request(host).get(service).end((err, res) => {
      res.should.have.status(200)
      done()
    })
  })
  let id_test = null
  it('rest post', (done) => {
    chai.request(host).post(service).send({
      name: "lada",
      engine: "2.0",
      id: "AEIOU"
    }).end((err, res) => {
      res.should.have.status(201)
      res.should.have.header('Location')
      res.body.should.be.a('object')
      let id = res.body.id
      id.should.be.a('string')
      id_test = id
      done()
    })
  })
  it('rest put', (done) => {
    chai.request(host).put(service + '/' + id_test).send({
      name: "lada",
      engine: "4.0",
      id: "AEIOU"
    }).end((err, res) => {
      res.should.have.status(204)
      done()
    })
  })
  it('rest delete', (done) => {
    chai.request(host).delete(service + '/' + id_test).end((err, res) => {
      res.should.have.status(200)
      done()
    })
  })
})

//----------------------responses as streams----------------------------------
describe('streams', () => {
  it('should return all static files as streams', (done) => {
    chai.request(host).get('/index.html').end((err, res) => {
      res.should.have.status(200)
      done()
    })
  })
  it('should return certain dynamic files as streams', (done) => {
    chai.request(host).get('/test-stream').end((err, res) => {
      res.should.have.status(200)
      done()
    })
  })
})

@@ -541,17 +541,16 @@
  %7D)%0A%7D)%0A%0A
-%0A
 //------
@@ -569,40 +569,39 @@
 ----
-static dynamic and rest requests
+index.html when default paths--
 ----
@@ -597,32 +597,33 @@
 paths-----------
+-
 %0Adescribe('reque
@@ -621,67 +621,551 @@
 be('
-requests', () =%3E %7B%0A  var service = '/cars'%0A  it('index page
+index.html pages', () =%3E %7B%0A  it('/-%3E index.html', (done) =%3E %7B%0A    chai.request(host).get('/').end((err, res) =%3E %7B%0A      res.should.have.status(200)%0A      done()%0A    %7D)%0A  %7D)%0A  it('/index -%3E index.html', (done) =%3E %7B%0A    chai.request(host).get('/index').end((err, res) =%3E %7B%0A      res.should.have.status(200)%0A      done()%0A    %7D)%0A  %7D)%0A  it('/details -%3E /details/index.html', (done) =%3E %7B%0A    chai.request(host).get('/details').end((err, res) =%3E %7B%0A      res.should.have.status(200)%0A      done()%0A    %7D)%0A  %7D)%0A  it('/details/index -%3E /details/index.html
 ', (
@@ -1196,32 +1196,40 @@
 est(host).get('/
+details/
 index').end((err
@@ -1291,32 +1291,155 @@
 e()%0A    %7D)%0A  %7D)%0A
+%7D)%0A%0A//----------------------static dynamic and rest requests---------%0Adescribe('requests', () =%3E %7B%0A  var service = '/cars'%0A
   it('rest get',

add inferred index.html paths