3802-ticket_sale_mana #924
|
@ -90,7 +90,7 @@ describe('sale updateDiscount()', () => {
|
||||||
expect(error.message).toEqual(`The sales of this ticket can't be modified`);
|
expect(error.message).toEqual(`The sales of this ticket can't be modified`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the discount if the salesPerson has mana', async() => {
|
it('should update the discount if the salesPerson has mana and manaType = "mana"', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -108,8 +108,49 @@ describe('sale updateDiscount()', () => {
|
||||||
const newDiscount = 100;
|
const newDiscount = 100;
|
||||||
const manaDiscount = await models.Component.findOne({where: {code: 'mana'}}, options);
|
const manaDiscount = await models.Component.findOne({where: {code: 'mana'}}, options);
|
||||||
const componentId = manaDiscount.id;
|
const componentId = manaDiscount.id;
|
||||||
|
const manaType = 'mana';
|
||||||
|
|
||||||
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, options);
|
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options);
|
||||||
|
|
||||||
|
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
|
||||||
|
const createdSaleComponent = await models.SaleComponent.findOne({
|
||||||
|
where: {
|
||||||
|
componentFk: componentId,
|
||||||
|
saleFk: originalSaleId
|
||||||
|
}
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
expect(createdSaleComponent.componentFk).toEqual(componentId);
|
||||||
|
expect(updatedSale.discount).toEqual(100);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should update the discount if the salesPerson has mana and manaType = "mana claim"', async() => {
|
||||||
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
const ctx = {
|
||||||
|
req: {
|
||||||
|
accessToken: {userId: 18},
|
||||||
|
headers: {origin: 'localhost:5000'},
|
||||||
|
__: () => {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const ticketId = 11;
|
||||||
|
const sales = [originalSaleId];
|
||||||
|
const newDiscount = 100;
|
||||||
|
const manaDiscount = await models.Component.findOne({where: {code: 'mana claim'}}, options);
|
||||||
|
const componentId = manaDiscount.id;
|
||||||
|
const manaType = 'mana claim';
|
||||||
|
|
||||||
|
await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaType, options);
|
||||||
|
|
||||||
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
|
const updatedSale = await models.Sale.findById(originalSaleId, null, options);
|
||||||
const createdSaleComponent = await models.SaleComponent.findOne({
|
const createdSaleComponent = await models.SaleComponent.findOne({
|
||||||
|
|
|
@ -28,7 +28,7 @@ module.exports = Self => {
|
||||||
arg: 'manaType',
|
arg: 'manaType',
|
||||||
description: 'The type of mana',
|
description: 'The type of mana',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true
|
required: false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
|
|
Loading…
Reference in New Issue