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

73 lines
2.6 KiB
JavaScript
Raw Normal View History

2018-02-27 13:55:59 +00:00
// const crudItemBarcodes = require('../crudItemBarcodes');
// const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
// let mysql = require('mysql2');
2018-02-14 15:49:19 +00:00
2018-02-27 13:55:59 +00:00
// describe('Item crudItemBarcodes()', () => {
// let connection;
// beforeAll(() => {
// connection = mysql.createConnection({
// multipleStatements: true,
// host: 'localhost',
// user: 'root',
// password: '',
// database: 'salix'
// });
// });
2018-02-27 13:55:59 +00:00
// it('should call the destroyAll methodif there are ids in delete Array', done => {
// let self = jasmine.createSpyObj('self', ['remoteMethod', 'crudItemBarcodes', 'destroyAll', 'create', 'upsert']);
2018-02-14 15:49:19 +00:00
2018-02-27 13:55:59 +00:00
// crudItemBarcodes(self);
// self.crudItemBarcodes({
// delete: [1],
// create: [],
// update: []
// }).then(result => {
// expect(self.destroyAll).toHaveBeenCalledWith({id: {inq: [1]}});
// done();
// })
// .catch(catchErrors(done));
// });
2018-02-14 15:49:19 +00:00
2018-02-27 13:55:59 +00:00
// it('should call the create method if there are ids in create Array', done => {
// let self = jasmine.createSpyObj('self', ['remoteMethod', 'crudItemBarcodes', 'destroyAll', 'create', 'upsert']);
2018-02-14 15:49:19 +00:00
2018-02-27 13:55:59 +00:00
// crudItemBarcodes(self);
// self.crudItemBarcodes({
// delete: [],
// create: [1],
// update: []
// }).then(result => {
// expect(self.create).toHaveBeenCalledWith([1]);
// done();
// })
// .catch(catchErrors(done));
// });
2018-02-14 15:49:19 +00:00
2018-02-27 13:55:59 +00:00
// 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']);
2018-02-14 15:49:19 +00:00
2018-02-27 13:55:59 +00:00
// 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));
// });
2018-02-27 13:55:59 +00:00
// 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();
// };
2018-02-27 13:55:59 +00:00
// connection.query('INSERT INTO `vn`.`itemBarcode` VALUES (4, 2 ,4 );', callback);
// });
// });