'use strict';

var ObjectId = require("mongodb").ObjectId;
var should = require('should');
var helper = require("../../helper");
var Manager = require("../../../src/managers/garment-master-plan/sewing-blocking-plan-manager");
var manager = null;
var dataUtil =require("../../data-util/garment-master-plan/sewing-blocking-plan-data-util");
var validate = require("dl-models").validator.garmentMasterPlan.sewingBlockingPlan;
require("should");

before('#00. connect db', function (done) {
    helper.getDb()
        .then(db => {
            manager = new Manager(db, {
                username: 'unit-test'
            });
            done();
        })
        .catch(e => {
            done(e);
        })
});
 var year=2018;
 var unit="C1A";
 
it("#01. should success when get report with parameter year", function (done) {
    manager.getReport({"year" : year})
        .then((data) => {
            data.should.instanceof(Array);
            done();
        })
        .catch((e) => {
            done(e);
        });
});
it("#01. should success when get report with parameter unit", function (done) {
    manager.getReport({"unit" : unit})
        .then((data) => {
            data.should.instanceof(Array);
            done();
        })
        .catch((e) => {
            done(e);
        });
});
@@ -253,16 +253,17 @@
 taUtil =
+ 
 require(
@@ -709,50 +709,710 @@
 %7D);%0A
- var year=2018;%0A var unit=%22C1A%22;%0A 
+%0Avar dummyData;%0Avar dummyDataId;%0Avar queryReport = %7B%7D;%0Avar dummyReportResult = %7B%7D;%0A%0Ait(%60#01. should success when get created new data%60, function (done) %7B%0A    dataUtil.getNewData()%0A        .then((data) =%3E %7B%0A            manager.create(data)%0A                .then((id) =%3E %7B%0A                    dummyDataId = id;%0A                    dummyData = data;%0A                    queryReport.year = dummyData.details%5B0%5D.weeklyPlanYear;%0A                    queryReport.unit = dummyData.details%5B0%5D.unit.code;%0A                    done();%0A                %7D)%0A                .catch((e) =%3E %7B%0A                    done(e);%0A                %7D);%0A        %7D)%0A        .catch((e) =%3E %7B%0A            done(e);%0A        %7D);%0A%7D);%0A
 %0Ait(%22#0
-1
+2
 . sh
@@ -1507,21 +1507,34 @@
 rt(%7B
+ 
 %22year%22
- 
 : 
+queryReport.
 year
+ 
 %7D)%0A 
@@ -1697,15 +1697,16 @@
 %7D);%0A
+%0A
 it(%22#0
-1
+3
 . sh
@@ -1749,16 +1749,25 @@
 rameter 
+year and 
 unit%22, f
@@ -1809,93 +1809,654 @@
 ort(
-%7B%22unit%22 : unit%7D)%0A        .then((data) =%3E %7B%0A            data.should.instanceof(Array);
+queryReport)%0A        .then((data) =%3E %7B%0A            data.should.instanceof(Array);%0A            dummyReportResult.data = data;%0A            done();%0A        %7D)%0A        .catch((e) =%3E %7B%0A            done(e);%0A        %7D);%0A%7D);%0A%0Ait(%22#04. should success when get report with parameter year and unit%22, function (done) %7B%0A    manager.getXls(dummyReportResult, queryReport)%0A        .then((data) =%3E %7B%0A            data.should.instanceof(Object);%0A            done();%0A        %7D)%0A        .catch((e) =%3E %7B%0A            done(e);%0A        %7D);%0A%7D);%0A%0Ait(%60#99. should success when remove all data%60, function(done) %7B%0A    manager.collection.remove(%7B%7D)%0A        .then((result) =%3E %7B
 %0A   

Edit unit test