salix/services/item/common/methods/item-barcode/spec/crudItemBarcodes.spec.js

73 lines
2.6 KiB
JavaScript

// const crudItemBarcodes = require('../crudItemBarcodes');
// const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
// let mysql = require('mysql2');
// describe('Item crudItemBarcodes()', () => {
// let connection;
// beforeAll(() => {
// connection = mysql.createConnection({
// multipleStatements: true,
// host: 'localhost',
// user: 'root',
// password: '',
// database: 'salix'
// });
// });
// it('should call the destroyAll methodif there are ids in delete Array', done => {
// let self = jasmine.createSpyObj('self', ['remoteMethod', 'crudItemBarcodes', 'destroyAll', 'create', 'upsert']);
// crudItemBarcodes(self);
// self.crudItemBarcodes({
// delete: [1],
// create: [],
// update: []
// }).then(result => {
// expect(self.destroyAll).toHaveBeenCalledWith({id: {inq: [1]}});
// done();
// })
// .catch(catchErrors(done));
// });
// it('should call the create method if there are ids in create Array', done => {
// let self = jasmine.createSpyObj('self', ['remoteMethod', 'crudItemBarcodes', 'destroyAll', 'create', 'upsert']);
// crudItemBarcodes(self);
// self.crudItemBarcodes({
// delete: [],
// create: [1],
// update: []
// }).then(result => {
// expect(self.create).toHaveBeenCalledWith([1]);
// done();
// })
// .catch(catchErrors(done));
// });
// it('should call the upsert method as many times as ids in update Array', done => {
// let self = jasmine.createSpyObj('self', ['remoteMethod', 'crudItemBarcodes', 'destroyAll', 'create', 'upsert']);
// crudItemBarcodes(self);
// self.crudItemBarcodes({
// delete: [],
// create: [],
// update: [1, 2]
// }).then(result => {
// expect(self.upsert).toHaveBeenCalledWith(1);
// expect(self.upsert).toHaveBeenCalledWith(2);
// expect(self.upsert.calls.count()).toEqual(2);
// done();
// })
// .catch(catchErrors(done));
// });
// it('should return an error when attempting to save a duplicated barcode', done => {
// let callback = (err, res) => {
// expect(err.toString()).toBe("Error: Duplicate entry '4' for key 'PRIMARY'");
// done();
// };
// connection.query('INSERT INTO `vn`.`itemBarcode` VALUES (4, 2 ,4 );', callback);
// });
// });