'use strict';
/* jshint esversion: 6, node: true, mocha: true */

const fs = require('fs');


describe.skip('Testing real website requests', () => {
  const mock = require('./mock.js');

  const test = mock.getTestFunction('../websites/aerosolcms.com/');

  const config = JSON.parse(fs.readFileSync('../websites/aerosolcms.com/' + '.aerosolcms/urlspace.json'));

  it('GET aerosolcms.com/ should return a html page with HTTP status 200', () => {
    return test('/', config)
        //.then(mock.displayOutput)
        .then(mock.isHTTPStatus200)
        .then(mock.contains('<html lang="en">'))
        .then(mock.contains('<title>AerosolCMS - The Cloud CMS</title>'))
        .then(mock.contains('<link rel="alternate" href="http://mocha-tests.aerosolcms.com/" hreflang="en" />'))
        .then(mock.contains('<script type="application/ld+json" id="ld+json-metadata">{"@context":"http://schema.org","@type"'))
        .then(mock.contains('<li>API'))
        .then(mock.contains('Imprint'));
  });

  it('GET aerosolcms.com/de should return a 301', () => {
    return test('/de', config)
        // .then(mock.displayOutput)
        .then(mock.isHTTPStatus('301'))
        .then(mock.hasHeaderValue('Location', '/de/'));
  });

  it('GET aerosolcms.com/de/ should return a html page with HTTP status 200 in german', () => {
    return test('/de/', config)
        // .then(mock.displayOutput)
        .then(mock.isHTTPStatus200)
        .then(mock.contains('<html lang="de">'))
        .then(mock.contains('<title>AerosolCMS - Das Cloud CMS</title>'))
        .then(mock.contains('<link rel="alternate" href="http://mocha-tests.aerosolcms.com/" hreflang="en" />'))
        .then(mock.contains('<script type="application/ld+json" id="ld+json-metadata">{"@context":"http://schema.org","@type"'))
        .then(mock.contains('<li>API'))
        .then(mock.contains('Impressum'));
  });

  it('GET aerosolcms.com/amp/ should return a amp html page with HTTP status 200', () => {
    return test('/amp/', config)
        //.then(mock.displayOutput)
        .then(mock.isHTTPStatus200)
        .then(mock.contains('<html amp lang="en">'))
        .then(mock.contains('<title>AerosolCMS - The Cloud CMS</title>'))
        .then(mock.contains('<link rel="alternate" href="http://mocha-tests.aerosolcms.com/amp/" hreflang="en" />'))
        .then(mock.contains('<script type="application/ld+json" id="ld+json-metadata">{"@context":"http://schema.org","@type":"WebSite"'))
        .then(mock.contains('<li>API'))
        .then(mock.contains('Imprint'));
  });

  it('GET aerosolcms.com/de/amp/ should return a amp html page with HTTP status 200 in german', () => {
    return test('/de/amp/', config)
        //.then(mock.displayOutput)
        .then(mock.isHTTPStatus200)
        .then(mock.contains('<html amp lang="de">'))
        .then(mock.contains('<title>AerosolCMS - Das Cloud CMS</title>'))
        .then(mock.contains('<link rel="alternate" href="http://mocha-tests.aerosolcms.com/amp/" hreflang="en" />'))
        .then(mock.contains('<script type="application/ld+json" id="ld+json-metadata">{"@context":"http://schema.org","@type":"WebSite","headline":"AerosolCMS - Das Cloud CMS"'))
        .then(mock.contains('<style amp-custom>html'))
        .then(mock.contains('<li>API'))
        .then(mock.contains('Impressum'));
  });

  it('GET aerosolcms.com/de/datenschutz.html should return a html page with HTTP status 200 in german', () => {
    return test('/de/datenschutz.html', config)
        //.then(mock.displayOutput)
        .then(mock.isHTTPStatus200)
        .then(mock.contains('<html lang="de">'))
        .then(mock.contains('<title>AerosolCMS - Das Cloud CMS - Datenschutz</title>'))
        .then(mock.contains('Impressum'));
  });

  it('GET aerosolcms.com/XYZ should return a html page with HTTP status 404', () => {
    return test('/XYZ', config)
        //.then(mock.displayOutput)
        .then(mock.isHTTPStatus('404'))
        .then(mock.contains('<html lang="en">'))
        .then(mock.contains('<title>AerosolCMS - The Cloud CMS</title>'))
        .then(mock.contains('<script type="application/ld+json" id="ld+json-metadata">{"@context":"http://schema.org","@type":"WebPage","headline":"AerosolCMS - The Cloud CMS"'))
        .then(mock.contains('<h1>This page does'))
        .then(mock.contains('Imprint'));
  });

  it('GET aerosolcms.com/ should return a html page with editor markup', () => {
    return test('/', config, true)
        // .then(mock.displayOutput)
        .then(mock.isHTTPStatus200)
        .then(mock.contains('<div id="aerosolcms-editor">'))
  });

});
