﻿var _ = require("lodash");
var should = require("should");

var Status = require("../../models/status");
var StatusController = require("../../controllers/status");
var dbhelper = require("../../controllers/dbhelper");

describe("controllers/status", function ()
{
    before(function (done)
    {
        if (dbhelper.connected())
        {
            dbhelper.dropAllCollections(done);
        }
        else
        {
            dbhelper.connect(function (err)
            {
                should.not.exist(err);
                dbhelper.dropAllCollections(done);
            });
        }
    });
    
    describe("1.init", function ()
    {
        it("should create a new status: Zoro, 20150915, 20150910", function (done)
        {
            new Status({
                username : "Zoro",
                startDate : "20150909",
                endDate : "20150910"
            }).save(done);
        });
    });
    
    describe("2.findStatusByUsername", function ()
    {
        var username = "Zoro";
        it("should find the status of user: '" + username + "'", function (done)
        {
            StatusController.findStatusByUsername(username, function (err, doc)
            {
                should.not.exist(err);
                should.exist(doc);
                doc.username.should.equal(username);
                done();
            });
        });
        
        var wrongUsername = " ";
        it("should not find the status of user: '" + wrongUsername + "'", function (done)
        {
            StatusController.findStatusByUsername(wrongUsername, function (err, doc)
            {
                should.not.exist(doc);
                done();
            });
        });
    });
    
    describe("3.saveStatus", function ()
    {
        it("should save the status of: Zoro, , 20150910", function (done)
        {
            var status = {
                username: "Zoro",
                endDate: "20150910"
            };
            
            StatusController.saveStatus(status, function (err, doc)
            {
                should.not.exist(err);
                should.exist(doc);
                doc.username.should.equal(status.username);
                doc.endDate.should.equal(status.endDate);
                done();
            });
        });
    });
});

@@ -1,62 +1,32 @@
 %EF%BB%BF
-var _ = require(%22lodash%22);%0D%0Avar should = require(
+import should from 
 %22should%22
 );%0D%0A
@@ -25,25 +25,27 @@
 uld%22
-)
 ;%0D%0A%0D%0A
-var
+import
  Status 
 = re
@@ -40,26 +40,21 @@
  Status 
-= require(
+from 
 %22../../m
@@ -66,23 +66,25 @@
 /status%22
-)
 ;%0D%0A
-var
+import
  StatusC
@@ -93,26 +93,21 @@
 troller 
-= require(
+from 
 %22../../c
@@ -128,15 +128,17 @@
 tus%22
-)
 ;%0D%0A
-var
+import
  dbh
@@ -147,18 +147,13 @@
 per 
-= require(
+from 
 %22../
@@ -176,17 +176,16 @@
 bhelper%22
-)
 ;%0D%0A%0D%0Ades
@@ -189,16 +189,21 @@
 describe
+.only
 (%22contro
@@ -995,19 +995,21 @@
         
-var
+const
  usernam
@@ -1413,19 +1413,21 @@
         
-var
+const
  wrongUs
@@ -1905,11 +1905,13 @@
     
-var
+const
  sta

update to es6