// Author Test File
var db = require('../tmp/db.js');
var assert = require('assert');

var author = {
    name: 'Slash',
    email: 'email@me.com',
 };

var author_update = {
    name: 'Morbid',
    email: 'morbid@angel.org',
}

var author_id;

describe('Author Table Test', function(){

    it('Should save new author', function(done){
       db.saveAuthor(author).then(function(status){
           //console.log(status);
	   author_id = status.generated_keys[0];
	   done();    
       }, function(err){     
           done(err);
       });
    })

    it('Should get author data based on id', function(done){
       db.getAuthorById(author_id).then(function(data) {
          //console.log(data);
          assert.equal(data.name,author.name, 'Author name ');
	  done();
       }, function(err){
          done(err);
       });   
    });
/**
    it('Should update post', function(){
       
       post_update.generated_keys = [post_id];

       db.updatePost(post_update).then(function(data){
           //console.log(data);
           assert.equal(1, data.replaced, 'replaced (updated) should be 1');
	   done();
       }, function(err){
           done(err);
       });
    })
*/

    it('Should delete author with specified id', function(done){
       db.deleteAuthor(author_id).then(function(result){
           //console.log(result);
	   assert.equal(1, result.deleted, 'deleted should be 1');
	   done();
       }, function(err){
           done(err);
       })
    })
})

@@ -840,11 +840,8 @@
 %7D);%0A
-/**
 %0A   
@@ -859,20 +859,27 @@
  update 
-post
+author data
 ', funct
@@ -900,20 +900,22 @@
 %0A       
-post
+author
 _update.
@@ -932,20 +932,22 @@
 keys = %5B
-post
+author
 _id%5D;%0A%0A 
@@ -965,17 +965,21 @@
 date
-Post(post
+Author(author
 _upd
@@ -1193,11 +1193,8 @@
   %7D)
-%0A*/
 %0A%0A  

Add test for author update