refactor: updated backTest
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b246a119cb
commit
1766222c12
|
@ -1,20 +1,20 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('sale refund()', () => {
|
describe('sale refund()', () => {
|
||||||
it('should create ticket with the selected lines changing the sign to the quantites', async() => {
|
|
||||||
const tx = await models.Sale.beginTransaction({});
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
|
|
||||||
const ticketId = 11;
|
|
||||||
const sales = [
|
const sales = [
|
||||||
{id: 7, ticketFk: 11},
|
{id: 7, ticketFk: 11},
|
||||||
{id: 8, ticketFk: 11}
|
{id: 8, ticketFk: 11}
|
||||||
];
|
];
|
||||||
|
const services = [{id: 1}];
|
||||||
|
|
||||||
|
it('should create ticket with the selected lines changing the sign to the quantites', async() => {
|
||||||
|
const tx = await models.Sale.beginTransaction({});
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const response = await models.Sale.refund(ctx, sales, ticketId, options);
|
const response = await models.Sale.refund(ctx, sales, services, options);
|
||||||
const [newTicketId] = await models.Sale.rawSql('SELECT MAX(t.id) id FROM vn.ticket t;', null, options);
|
const [newTicketId] = await models.Sale.rawSql('SELECT MAX(t.id) id FROM vn.ticket t;', null, options);
|
||||||
|
|
||||||
expect(response).toEqual(newTicketId.id);
|
expect(response).toEqual(newTicketId.id);
|
||||||
|
@ -30,17 +30,12 @@ describe('sale refund()', () => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
const ctx = {req: {accessToken: {userId: 1}}};
|
const ctx = {req: {accessToken: {userId: 1}}};
|
||||||
|
|
||||||
const ticketId = 11;
|
|
||||||
const sales = [
|
|
||||||
{id: 7, ticketFk: 11}
|
|
||||||
];
|
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
await models.Sale.refund(ctx, sales, ticketId, options);
|
await models.Sale.refund(ctx, sales, services, options);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in New Issue