// DO NOT use arrow functions in testing

// supertest reference: https://www.npmjs.com/package/supertest

const assert = require('chai').assert;
const request = require('supertest');
const express = require('express');
const app = express();


describe('GET /', function() {
  it('should respond with html', function(done) {
    request(app)
      .get('/')
      .set('Accept', 'application/html')
      .expect('Content-type', /utf-8/)
      .expect(200)
      .end(function(err, res) {
        if (err) return done(err);
        done();
      });
  });
});

describe('GET and POST to /api/meeting', function() {
  it('should respond with json', function(done) {
    request(app)
      .get('/api/meeting')
      .set('Accept', 'application/json')
      .expect('Content-type', 'text/html; charset=utf-8')
      .expect(200)
      .end(function(err, res) {
        if (err) return done(err);
        done();
      });
  });

  it('should respond with json', function(done) {
    request(app)
    .post('/api/meeting')
    .send({owner_id: 1, room_url: 'supertest POST request', time: new Date('April 11, 2017 03:24:00')})
    .set('Accept', 'application/json')
    .expect('Content-type', 'text/html; charset=utf-8')
    .expect(200)
    .then(function(err, res) {
      if (err) return done(err);
      assert(res.body.room_url, 'supertest POST request');
    })
  });
});

describe('GET and POST to /api/user', function() {
  it('should respond with json', function(done) {
    request(app)
      .get('/api/user')
      .set('Accept', 'application/json')
      .expect('Content-type', 'text/html; charset=utf-8')
      .expect(200)
      .end(function(err, res) {
        if (err) return done(err);
        done();
      });
  });

  it('should respond with json', function(done) {
    request(app)
    .post('/api/user')
    .send({username: 'supertestTest', email: 'ghost@gmails.com'})
    .set('Accept', 'application/json')
    .expect('Content-type', 'text/html; charset=utf-8')
    .expect(200)
    .then(function(err, res) {
      if (err) return done(err);
      assert(res.body.email, 'ghost@gmails.com')
    })
  });
});

@@ -295,20 +295,20 @@
 nd with 
-html
+json
 ', funct
@@ -356,49 +356,8 @@
 /')%0A
-      .set('Accept', 'application/html')%0A
     
@@ -666,49 +666,8 @@
 g')%0A
-      .set('Accept', 'application/json')%0A
     
@@ -696,34 +696,14 @@
 e', 
-'text/html; charset=utf-8'
+/json/
 )%0A  
@@ -1020,47 +1020,8 @@
 )%7D)%0A
-    .set('Accept', 'application/json')%0A
     
@@ -1048,34 +1048,14 @@
 e', 
-'text/html; charset=utf-8'
+/json/
 )%0A  
@@ -1362,99 +1362,40 @@
     
-.set('Accept', 'application/json')%0A      .expect('Content-type', 'text/html; charset=utf-8'
+  .expect('Content-type', /json/
 )%0A  
@@ -1671,47 +1671,8 @@
 '%7D)%0A
-    .set('Accept', 'application/json')%0A
     
@@ -1699,34 +1699,14 @@
 e', 
-'text/html; charset=utf-8'
+/json/
 )%0A  

Refactor tests to expect json back