"use strict";

var assert = require('assert');
var api = require('../api');
var parser = require('../parser');
var fs = require('fs');
var request = require('request');

describe('Api', function(){

  before(function () {
    api.startApi();
  });

  after(function () {
    api.stopApi();
  });

  it('api should be defined', function() {
    assert.notEqual(typeof api, 'undefined');
  });

  it('startApi should be a function', function() {
    assert.equal(typeof api.startApi, 'function');
  });

  it('/ should return 200', function(done) {
    request("http://localhost:8088/api/v0/", function(error, response, html) {
      assert.equal(response.statusCode, 200);
      done();
    });
  });

  it('/deadlines should return 200', function(done) {
    request("http://localhost:8088/api/v0/deadlines/", function(error, response, html) {
      assert.equal(response.statusCode, 200);
      done();
    });
  });

  it('/lectures should return 200', function(done) {
    request("http://localhost:8088/api/v0/lectures", function(error, response, html) {
      assert.equal(response.statusCode, 200);
      done();
    });
  });
});

@@ -491,24 +491,58 @@
 n');%0A  %7D);%0A%0A
+  describe('http', function() %7B%0A  
   it('/ shou
@@ -570,32 +570,34 @@
 ion(done) %7B%0A    
+ 
+ 
 request(%22http://
@@ -653,32 +653,34 @@
 , html) %7B%0A      
+  
 assert.equal(res
@@ -701,32 +701,34 @@
 de, 200);%0A      
+ 
+ 
 done();%0A    %7D);%0A
@@ -719,35 +719,41 @@
 done();%0A    
+  
 %7D);%0A  
+ 
+ 
 %7D);%0A%0A
+  
   it('/deadl
@@ -790,32 +790,34 @@
 ion(done) %7B%0A    
+ 
+ 
 request(%22http://
@@ -883,32 +883,34 @@
 , html) %7B%0A      
+  
 assert.equal(res
@@ -931,32 +931,34 @@
 de, 200);%0A      
+  
 done();%0A    %7D);%0A
@@ -957,19 +957,25 @@
     
+  
 %7D);%0A  
+ 
+ 
 %7D);%0A%0A
+  
   it
@@ -1019,24 +1019,26 @@
 ion(done) %7B%0A
+  
     request(
@@ -1108,24 +1108,26 @@
 se, html) %7B%0A
+  
       assert
@@ -1162,24 +1162,26 @@
 200);%0A      
+  
 done();%0A    
@@ -1180,20 +1180,946 @@
 ();%0A    
+  
 %7D);%0A
+    %7D);%0A%0A    var id = %22%22;%0A    it('it should create deadline', function(done) %7B%0A        var deadline = %7B%0A            info: 'Do it!',%0A            deadline: new Date()%0A        %7D;%0A%0A        var conf = %7B%0A            url: 'http://localhost:8088/api/v0/deadlines/',%0A            form: deadline%0A        %7D;%0A%0A        // create a deadline%0A        request.post(conf, function(error, response, body) %7B%0A            assert.equal(response.statusCode, 200);%0A            id = JSON.parse(body).id;%0A            assert.notEqual(typeof id, 'undefined');%0A            done();%0A        %7D);%0A    %7D);%0A%0A    it('it should have deadline', function(done) %7B%0A        var url = 'http://localhost:8088/api/v0/deadlines/' + id;%0A        request(url, function(error, response, html) %7B%0A            assert.equal(response.statusCode, 200);%0A            var info = JSON.parse(html).info;%0A            assert.equal(info, 'Do it!');%0A            done();%0A        %7D);%0A    %7D);%0A%0A
   %7D);%0A%7D)

test creation of deadlines