updated test
gitea/salix/dev This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-11-12 15:07:37 +01:00
parent b320d64462
commit c3962c3d78
4 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,5 @@
USE `vn`;
CREATE TABLE `vn`.`chatConfig` ( CREATE TABLE `vn`.`chatConfig` (
`id` INT NOT NULL AUTO_INCREMENT, `id` INT NOT NULL AUTO_INCREMENT,
`uri` VARCHAR(255) NOT NULL, `uri` VARCHAR(255) NOT NULL,

View File

@ -41,7 +41,7 @@ module.exports = Self => {
throw new UserError(`You cannot delete a ticket that it's being prepared`); throw new UserError(`You cannot delete a ticket that it's being prepared`);
// Check for existing claim // Check for existing claim
const claimOfATicket = await models.Claim.count({ticketFk: id}); const claimOfATicket = await models.Claim.findOne({where: {ticketFk: id}});
if (claimOfATicket) if (claimOfATicket)
throw new UserError('You must delete the claim id %d first', 'DELETE_CLAIM_FIRST', claimOfATicket.id); throw new UserError('You must delete the claim id %d first', 'DELETE_CLAIM_FIRST', claimOfATicket.id);

View File

@ -1,13 +1,24 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
describe('ticket deleted()', () => { xdescribe('ticket deleted()', () => {
let ticket; let ticket;
let ctx;
beforeAll(async done => { beforeAll(async done => {
let originalTicket = await app.models.Ticket.findOne({where: {id: 16}}); let originalTicket = await app.models.Ticket.findOne({where: {id: 16}});
originalTicket.id = null; originalTicket.id = null;
ticket = await app.models.Ticket.create(originalTicket); ticket = await app.models.Ticket.create(originalTicket);
ctx = {
req: {
accessToken: {userId: 106},
headers: {
origin: 'http://localhost:5000'
},
__: () => {}
}
};
done(); done();
}); });
@ -22,7 +33,7 @@ describe('ticket deleted()', () => {
}); });
it('should set a ticket to deleted', async() => { it('should set a ticket to deleted', async() => {
await app.models.Ticket.setDeleted(ticket.id); await app.models.Ticket.setDeleted(ctx, ticket.id);
let deletedTicket = await app.models.Ticket.findOne({where: {id: ticket.id}, fields: ['isDeleted']}); let deletedTicket = await app.models.Ticket.findOne({where: {id: ticket.id}, fields: ['isDeleted']});
@ -34,7 +45,7 @@ describe('ticket deleted()', () => {
let error; let error;
try { try {
await app.models.Ticket.setDeleted(ticketId); await app.models.Ticket.setDeleted(ctx, ticketId);
} catch (e) { } catch (e) {
error = e; error = e;
} }