3802-ticket_sale_mana #924

Merged
carlosjr merged 10 commits from 3802-ticket_sale_mana into dev 2022-04-11 10:50:20 +00:00
2 changed files with 44 additions and 3 deletions
Showing only changes of commit 86350b2afa - Show all commits

View File

@ -90,7 +90,7 @@ describe('sale updateDiscount()', () => {
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({});
try {
@ -108,8 +108,49 @@ describe('sale updateDiscount()', () => {
const newDiscount = 100;
const manaDiscount = await models.Component.findOne({where: {code: 'mana'}}, options);
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() => {
vicent marked this conversation as resolved Outdated

if the code gets updated to lowerCamelCase this line and the test should be updated to match the code.

also manaType doesn't seem to be correct, manaCode or manaComponentCode are more specifics

if the code gets updated to lowerCamelCase this line and the test should be updated to match the code. also manaType doesn't seem to be correct, manaCode or manaComponentCode are more specifics
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 createdSaleComponent = await models.SaleComponent.findOne({

View File

@ -28,7 +28,7 @@ module.exports = Self => {
arg: 'manaType',
vicent marked this conversation as resolved Outdated

manaCode

manaCode
description: 'The type of mana',
type: 'string',
required: true
required: false
}
],
returns: {