import test from 'ava';
import request from 'supertest';
import punchcard from '../';

// cue up our application for all tests
test.beforeEach((t) => {
  return punchcard().then(app => {
    // Ignoring this param reassign as it's the standard for AVA to allow users to assign context to the tests
    t.context.request = request(app); // eslint-disable-line no-param-reassign

    return app;
  });
});

test.cb('CMS Landing Page', t => {
  t.context.request
    .get('/')
    .end((err, res) => {
      t.is(err, null, 'Should not have an error');
      t.is(res.status, 200, 'should return status 200');
      t.regex(res.text, /DOCTYPE html/, 'should have an html doctype');
      t.end();
    });
});

test.cb('Content Landing Page', t => {
  t.context.request
    .get('/content')
    .end((err, res) => {
      t.is(err, null, 'Should not have an error');
      t.is(res.status, 200, 'should return status 200');
      t.regex(res.text, /DOCTYPE html/, 'should have an html doctype');
      t.end();
    });
});

test.cb('Content Type Landing Page', t => {
  t.context.request
    .get('/content/services')
    .end((err, res) => {
      t.is(err, null, 'Should not have an error');
      t.is(res.status, 200, 'should return status 200');
      t.regex(res.text, /DOCTYPE html/, 'should have an html doctype');
      t.end();
    });
});

test.cb('Content Type Add Page', t => {
  t.context.request
    .get('/content/services/add')
    .end((err, res) => {
      t.is(err, null, 'Should not have an error');
      t.is(res.status, 200, 'should return status 200');
      t.regex(res.text, /DOCTYPE html/, 'should have an html doctype');
      t.end();
    });
});

test.cb('404 Page', t => {
  t.context.request
    .get('/foo')
    .end((err, res) => {
      t.is(err, null, 'Should not have an error');
      t.is(res.status, 404, 'should return status 404');
      t.end();
    });
});

@@ -1332,32 +1332,287 @@
 );%0A    %7D);%0A%7D);%0A%0A
+test.cb('Invalid Content Type - Landing', t =%3E %7B%0A  t.context.request%0A    .get('/content/foo')%0A    .end((err, res) =%3E %7B%0A      t.is(err, null, 'Should not have an error');%0A      t.is(res.status, 404, 'should return status 404');%0A      t.end();%0A    %7D);%0A%7D);%0A%0A
 test.cb('Content
@@ -1914,32 +1914,287 @@
 );%0A    %7D);%0A%7D);%0A%0A
+test.cb('Invalid Content Type - Add', t =%3E %7B%0A  t.context.request%0A    .get('/content/foo/add')%0A    .end((err, res) =%3E %7B%0A      t.is(err, null, 'Should not have an error');%0A      t.is(res.status, 404, 'should return status 404');%0A      t.end();%0A    %7D);%0A%7D);%0A%0A
 test.cb('404 Pag

Add proper 404 tests