fix test
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
566d384483
commit
153cb48ff0
|
@ -333,7 +333,7 @@ INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city
|
|||
(1109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Gotham', 46460, 1111111111, 222222222, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, 9, 0, 1, 'florist'),
|
||||
(1110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Gotham', 46460, 1111111111, 222222222, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1, 'florist'),
|
||||
(1111, 'Missing', NULL, 'Missing man', 'Anton', 'The space, Universe far away', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, NULL),
|
||||
(1112, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city, Underground', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, NULL);
|
||||
(1112, 'Trash', '12345678Z', 'Garbage man', 'Unknown name', 'New York city, Underground', 'Gotham', 46460, 1111111111, 222222222, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5, util.VN_CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1, NULL);
|
||||
|
||||
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
|
||||
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, util.VN_CURDATE(), 1
|
||||
|
@ -2701,7 +2701,7 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`)
|
|||
INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`)
|
||||
VALUES
|
||||
(1, 9);
|
||||
|
||||
|
||||
INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`)
|
||||
VALUES
|
||||
(0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6);
|
||||
|
|
|
@ -44,7 +44,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.missingTrash = async function (ctx, saleFk, quantity, isTrash, warehouseFk, newQuantity, options) {
|
||||
Self.missingTrash = async function(ctx, saleFk, quantity, isTrash, warehouseFk, newQuantity, options) {
|
||||
const myOptions = {};
|
||||
let tx;
|
||||
if (typeof options == 'object')
|
||||
|
|
|
@ -1,31 +1,50 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('sale missingTrash()', () => {
|
||||
it('should modify the amount of a sale by throwing it to faults or garbage', async () => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'localhost:5000'},
|
||||
__: () => {}
|
||||
};
|
||||
|
||||
const ctx = {
|
||||
req: activeCtx
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
|
||||
it('should modify the amount of a sale by throwing it to faults or garbage', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = { transaction: tx };
|
||||
const options = {transaction: tx};
|
||||
|
||||
const quantity = 1;
|
||||
const isTrash = true;
|
||||
|
||||
const ctx = { req: { accessToken: { userId: 9 } } };
|
||||
const trashClient = await models.Client.findOne({where: {name: 'Trash'}}, options);
|
||||
await trashClient.updateAttribute('name', 'BASURA', options);
|
||||
|
||||
const sale = await models.Sale.findOne({fields: ['id', 'quantity', 'originalQuantity', 'ticketFk']}
|
||||
, options);
|
||||
|
||||
const sale = await models.Sale.findOne({fields: ['id','quantity', 'originalQuantity', 'ticketFk']}, options);
|
||||
console.log(sale);
|
||||
const ticket = await models.Ticket.findById(sale.ticketFk, {fields: ['warehouseFk']}, options);
|
||||
console.log(ticket);
|
||||
const newQuantity = sale.quantity-quantity;
|
||||
|
||||
const newQuantity = sale.quantity - quantity;
|
||||
|
||||
await models.Sale.missingTrash(ctx, sale.id, quantity, isTrash, ticket.warehouseFk, newQuantity, options);
|
||||
|
||||
const saleAfter = await models.Sale.findById(sale.id, {fields: ['quantity', 'originalQuantity']}, options);
|
||||
|
||||
expect(saleAfter.quantity).toEqual(newQuantity);
|
||||
expect(saleAfter.originalQuantity).toBe(sale.quantity);
|
||||
|
||||
await tx.rollback();
|
||||
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
|
|
Loading…
Reference in New Issue