var assert = require('chai').assert;
var http = require('http');
var mathServer = require('../lib/mathServer.js');
var request = require('supertest');

process.env.NODE_ENV = 'test';

describe.only('Acceptance test', function () {
    var port = 8006;
    var server;

    before(function () {
        server = mathServer.MathServer({
            port: port,
            CONTAINERS: './dummy_containers.js'
        });
        server.listen();
        request = request('http://localhost:' + port);
    });

    after(function (done) {
        server.close();
        done();
    });

    describe('As basic behavior we', function () {
        it('should be able to create server and get title from html body', function (done) {
            http.get("http://127.0.0.1:" + port, function (res) {
                res.on('data', function (body) {
                    var str = body.toString('utf-8');
                    var n = str.match(/<title>\s*([^\s]*)\s*<\/title>/);
                    assert.equal(n[1], 'Macaulay2');
                    done();
                });
            });
        });
        it('should show title', function (done) {
            request.get('/').expect(200).end(function(error, result) {
                assert.match(result.text, /<title>\s*Macaulay2\s*<\/title>/);
                done();
            });
        });
    });
});

var assert = require('chai').assert;
var http = require('http');
var mathServer = require('../lib/mathServer.js');
var request = require('supertest');

process.env.NODE_ENV = 'test';

describe.only('Acceptance test', function () {
    var port = 8006;
    var server;

    before(function () {
        server = mathServer.MathServer({
            port: port,
            CONTAINERS: './dummy_containers.js'
        });
        server.listen();
        request = request('http://localhost:' + port);
    });

    after(function (done) {
        server.close();
        done();
    });

    describe('As basic behavior we', function () {
        it('should be able to create server and get title from html body', function (done) {
            http.get("http://127.0.0.1:" + port, function (res) {
                res.on('data', function (body) {
                    var str = body.toString('utf-8');
                    var n = str.match(/<title>\s*([^\s]*)\s*<\/title>/);
                    assert.equal(n[1], 'Macaulay2');
                    done();
                });
            });
        });
        it('should show title', function (done) {
            request.get('/').expect(200).end(function(error, result) {
                assert.match(result.text, /<title>\s*Macaulay2\s*<\/title>/);
                done();
            });
        });
        it('should get statistics', function (done) {
            request.get('/admin').expect(200).end(function(error, result) {
                assert.match(result.text, /<h1>Macaulay2 User Statistics<\/h1>/);
                done();
            });
        });
    });
});

Add test for showing statistics