<commit_before>'use strict';
var should = require('should');
var helper = require("../../helper");
var Manager = require("../../../src/managers/inventory-textile/textile-inventory-movement-manager");
var manager = null;
var dataUtil = require("../../data-util/inventory-textile/textile-inventory-movement-data-util");
var validate = require("dl-models").validator.inventoryTextile.textileInventoryMovement;

before('#00. connect db', function (done) {
    helper.getDb()
        .then(db => {
            manager = new Manager(db, {
                username: 'unit-test'
            });
            done();
        })
        .catch(e => {
            done(e);
        })
});

it('#01. should error when create new data without productId, uomId, storageId, referenceNo, referenceType', function (done) {
    dataUtil.getNewData()
        .then(data => {
            
            data.storageId={};
            data.productId={};
            data.uomId={};
            data.referenceNo="";
            data.referenceType="";

            inventoryDocumentManager.create(data)
                .then(id => {
                    done("should error when create new data without productId, uomId, storageId, referenceNo, referenceType");
                })
                .catch(e => {
                    try {
                        e.errors.should.have.property('storageId');
                        e.errors.should.have.property('productId');
                        e.errors.should.have.property('uomId');
                        e.errors.should.have.property('referenceType');
                        e.errors.should.have.property('referenceNo');
                        done();
                    }
                    catch (ex) {
                        done(ex);
                    }
                });
        })
        .catch(e => {
            done(e);
        });
});<commit_msg>fox unit test<commit_after>'use strict';
var should = require('should');
var helper = require("../../helper");
var Manager = require("../../../src/managers/inventory-textile/textile-inventory-movement-manager");
var manager = null;
var dataUtil = require("../../data-util/inventory-textile/textile-inventory-movement-data-util");
var validate = require("dl-models").validator.inventoryTextile.textileInventoryMovement;

before('#00. connect db', function (done) {
    helper.getDb()
        .then(db => {
            manager = new Manager(db, {
                username: 'unit-test'
            });
            done();
        })
        .catch(e => {
            done(e);
        })
});

it('#01. should error when create new data without productId, uomId, storageId, referenceNo, referenceType', function (done) {
    dataUtil.getNewData()
        .then(data => {
            
            data.storageId={};
            data.productId={};
            data.uomId={};
            data.referenceNo="";
            data.referenceType="";

            manager.create(data)
                .then(id => {
                    done("should error when create new data without productId, uomId, storageId, referenceNo, referenceType");
                })
                .catch(e => {
                    try {
                        e.errors.should.have.property('storageId');
                        e.errors.should.have.property('productId');
                        e.errors.should.have.property('uomId');
                        e.errors.should.have.property('referenceType');
                        e.errors.should.have.property('referenceNo');
                        done();
                    }
                    catch (ex) {
                        done(ex);
                    }
                });
        })
        .catch(e => {
            done(e);
        });
});
{'fraction_non_alphanumeric': 0.1432740780047758, 'fraction_numerical': 0.0021225789334040858, 'mean_word_length': 1.4656638325703073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '416699', 'n_tokens_mistral': 989, 'n_tokens_neox': 951, 'n_words': 170}