import http from "http";
import __polyfill from "babel-polyfill";
import should from 'should';
import jsdom from "jsdom";
import querystring from "querystring";
import serverApp from "./app";

describe("Isotropy", () => {

  const makeRequest = (host, port, path, method, headers, _postData) => {
    return new Promise((resolve, reject) => {
      const postData = (typeof _postData === "string") ? _postData : querystring.stringify(_postData);
      const options = { host, port, path, method, headers };

      let result = "";
      const req = http.request(options, function(res) {
        res.setEncoding('utf8');
        res.on('data', function(data) { result += data; });
        res.on('end', function() { resolve(result); });
      });
      req.on('error', function(e) { reject(e); });
      req.write(postData);
      req.end();
    });
  };

  it(`Should load an isomorphic page at /`, async () => {
    const defaultInstance = await serverApp();

    const html = await makeRequest("localhost", 8080, `/books/200`, "GET", { 'Content-Type': 'application/x-www-form-urlencoded' }, {});

    //Make sure we got what we wanted.
    html.trim().should.startWith("<html>");

    //Load html in jsdom
    return new Promise(function(resolve, reject) {
      jsdom.env(
        html,
        function (err, window) {
          if (err) {
            reject(err);
          } else {
            if (window.document.readyState != 'loading'){
            } else {
              window.document.addEventListener("DOMContentLoaded", function(event) {
                resolve("DOM fully loaded and parsed");
              });
            }
          }
        }
      );
    });
  });
});

@@ -218,1471 +218,8 @@
 =%3E %7B
-%0A%0A  const makeRequest = (host, port, path, method, headers, _postData) =%3E %7B%0A    return new Promise((resolve, reject) =%3E %7B%0A      const postData = (typeof _postData === %22string%22) ? _postData : querystring.stringify(_postData);%0A      const options = %7B host, port, path, method, headers %7D;%0A%0A      let result = %22%22;%0A      const req = http.request(options, function(res) %7B%0A        res.setEncoding('utf8');%0A        res.on('data', function(data) %7B result += data; %7D);%0A        res.on('end', function() %7B resolve(result); %7D);%0A      %7D);%0A      req.on('error', function(e) %7B reject(e); %7D);%0A      req.write(postData);%0A      req.end();%0A    %7D);%0A  %7D;%0A%0A  it(%60Should load an isomorphic page at /%60, async () =%3E %7B%0A    const defaultInstance = await serverApp();%0A%0A    const html = await makeRequest(%22localhost%22, 8080, %60/books/200%60, %22GET%22, %7B 'Content-Type': 'application/x-www-form-urlencoded' %7D, %7B%7D);%0A%0A    //Make sure we got what we wanted.%0A    html.trim().should.startWith(%22%3Chtml%3E%22);%0A%0A    //Load html in jsdom%0A    return new Promise(function(resolve, reject) %7B%0A      jsdom.env(%0A        html,%0A        function (err, window) %7B%0A          if (err) %7B%0A            reject(err);%0A          %7D else %7B%0A            if (window.document.readyState != 'loading')%7B%0A            %7D else %7B%0A              window.document.addEventListener(%22DOMContentLoaded%22, function(event) %7B%0A                resolve(%22DOM fully loaded and parsed%22);%0A              %7D);%0A            %7D%0A          %7D%0A        %7D%0A      );%0A    %7D);%0A  %7D);
 %0A%7D);

Remove tests.