some tests fixed
This commit is contained in:
parent
27d2c59358
commit
89fb980f14
|
@ -1,55 +1,17 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('chat sendCheckingPresence()', () => {
|
||||
const departmentId = 23;
|
||||
const workerId = 107;
|
||||
let timeEntry;
|
||||
|
||||
afterAll(async done => {
|
||||
const department = await app.models.Department.findById(departmentId);
|
||||
await department.updateAttribute('chatName', null);
|
||||
await app.models.WorkerTimeControl.destroyById(timeEntry.id);
|
||||
done();
|
||||
});
|
||||
|
||||
it(`should call to send() method with the worker username when no department channel is specified
|
||||
and then return a "Fake notification sent" as response`, async() => {
|
||||
const ctx = {req: {accessToken: {userId: 1}}};
|
||||
const chatModel = app.models.Chat;
|
||||
spyOn(chatModel, 'send').and.callThrough();
|
||||
|
||||
const response = await chatModel.sendCheckingPresence(ctx, workerId, 'I changed something');
|
||||
|
||||
expect(response.statusCode).toEqual(200);
|
||||
expect(response.message).toEqual('Fake notification sent');
|
||||
expect(chatModel.send).toHaveBeenCalledWith(ctx, '@HankPym', 'I changed something');
|
||||
});
|
||||
|
||||
it(`should call to send() method with the worker department channel if is specified
|
||||
and then return a "Fake notification sent" as response`, async() => {
|
||||
const ctx = {req: {accessToken: {userId: 1}}};
|
||||
const chatModel = app.models.Chat;
|
||||
spyOn(chatModel, 'send').and.callThrough();
|
||||
|
||||
const department = await app.models.Department.findById(departmentId);
|
||||
await department.updateAttribute('chatName', 'cooler');
|
||||
|
||||
const response = await chatModel.sendCheckingPresence(ctx, workerId, 'I changed something');
|
||||
|
||||
expect(response.statusCode).toEqual(200);
|
||||
expect(response.message).toEqual('Fake notification sent');
|
||||
expect(chatModel.send).toHaveBeenCalledWith(ctx, '#cooler', '@HankPym => I changed something');
|
||||
});
|
||||
|
||||
it(`should call to send() method with the worker username when the worker is working`, async() => {
|
||||
const ctx = {req: {accessToken: {userId: 1}}};
|
||||
const chatModel = app.models.Chat;
|
||||
spyOn(chatModel, 'send').and.callThrough();
|
||||
|
||||
const today = new Date();
|
||||
today.setHours(6, 0);
|
||||
const ctx = {req: {accessToken: {userId: 1}}};
|
||||
const chatModel = app.models.Chat;
|
||||
const departmentId = 23;
|
||||
const workerId = 107;
|
||||
|
||||
timeEntry = await app.models.WorkerTimeControl.create({
|
||||
it(`should call send() method with the worker name if he's currently working then return a response`, async() => {
|
||||
spyOn(chatModel, 'send').and.callThrough();
|
||||
|
||||
const timeEntry = await app.models.WorkerTimeControl.create({
|
||||
userFk: workerId,
|
||||
timed: today,
|
||||
manual: false,
|
||||
|
@ -61,5 +23,24 @@ describe('chat sendCheckingPresence()', () => {
|
|||
expect(response.statusCode).toEqual(200);
|
||||
expect(response.message).toEqual('Fake notification sent');
|
||||
expect(chatModel.send).toHaveBeenCalledWith(ctx, '@HankPym', 'I changed something');
|
||||
|
||||
// restores
|
||||
await app.models.WorkerTimeControl.destroyById(timeEntry.id);
|
||||
});
|
||||
|
||||
it(`should call to send() method with the worker department channel if he's not currently working then return a response`, async() => {
|
||||
spyOn(chatModel, 'send').and.callThrough();
|
||||
|
||||
const department = await app.models.Department.findById(departmentId);
|
||||
await department.updateAttribute('chatName', 'cooler');
|
||||
|
||||
const response = await chatModel.sendCheckingPresence(ctx, workerId, 'I changed something');
|
||||
|
||||
expect(response.statusCode).toEqual(200);
|
||||
expect(response.message).toEqual('Fake notification sent');
|
||||
expect(chatModel.send).toHaveBeenCalledWith(ctx, '#cooler', '@HankPym => I changed something');
|
||||
|
||||
// restores
|
||||
await department.updateAttribute('chatName', null);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,41 +2,37 @@ const app = require('vn-loopback/server/server');
|
|||
|
||||
describe('Model crud()', () => {
|
||||
let insertId;
|
||||
let ItemBarcode = app.models.ItemBarcode;
|
||||
const barcodeModel = app.models.ItemBarcode;
|
||||
|
||||
it('should inherit crud method from VnModel', () => {
|
||||
expect(ItemBarcode.crud).toBeDefined();
|
||||
expect(barcodeModel.crud).toBeDefined();
|
||||
});
|
||||
|
||||
it('should create a new instance', async() => {
|
||||
let data = {code: '500', itemFk: '1'};
|
||||
let creates = [data];
|
||||
it('should create, edit and delete an instance', async() => {
|
||||
let barcodeData = {code: '500', itemFk: '1'};
|
||||
let creates = [barcodeData];
|
||||
|
||||
await ItemBarcode.crud(null, null, creates);
|
||||
let instance = await ItemBarcode.findOne({where: data});
|
||||
await barcodeModel.crud(null, null, creates);
|
||||
let instance = await barcodeModel.findOne({where: barcodeData});
|
||||
insertId = instance.id;
|
||||
|
||||
expect(instance).not.toEqual(null);
|
||||
expect(instance.code).toEqual('500');
|
||||
});
|
||||
|
||||
it('should update the instance', async() => {
|
||||
let updates = [{
|
||||
where: {id: insertId},
|
||||
data: {code: '501', itemFk: 1}
|
||||
}];
|
||||
|
||||
await ItemBarcode.crud(null, updates);
|
||||
let instance = await ItemBarcode.findById(insertId);
|
||||
await barcodeModel.crud(null, updates);
|
||||
let editedInstance = await barcodeModel.findById(insertId);
|
||||
|
||||
expect(instance.code).toEqual('501');
|
||||
});
|
||||
expect(editedInstance.code).toEqual('501');
|
||||
|
||||
it('should delete the created instance', async() => {
|
||||
let deletes = [insertId];
|
||||
await ItemBarcode.crud(deletes);
|
||||
let instance = await ItemBarcode.findById(insertId);
|
||||
await barcodeModel.crud(deletes);
|
||||
let deletedInstance = await barcodeModel.findById(insertId);
|
||||
|
||||
expect(instance).toEqual(null);
|
||||
expect(deletedInstance).toEqual(null);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('Claim createFromSales()', () => {
|
||||
let createdClaimFk;
|
||||
|
||||
afterAll(async done => {
|
||||
await app.models.Claim.destroyById(createdClaimFk);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
const ticketId = 2;
|
||||
const newSale = [{
|
||||
id: 3,
|
||||
|
@ -27,10 +19,16 @@ describe('Claim createFromSales()', () => {
|
|||
expect(claimBeginning.saleFk).toEqual(newSale[0].id);
|
||||
expect(claimBeginning.quantity).toEqual(newSale[0].quantity);
|
||||
|
||||
createdClaimFk = claim.id;
|
||||
const createdClaimId = claim.id;
|
||||
|
||||
// restores
|
||||
await app.models.Claim.destroyById(createdClaimId);
|
||||
});
|
||||
|
||||
it('should not be able to create a claim if exists that sale', async() => {
|
||||
let claim = await app.models.Claim.createFromSales(ctx, ticketId, newSale);
|
||||
const createdClaimId = claim.id;
|
||||
|
||||
let error;
|
||||
|
||||
await app.models.Claim.createFromSales(ctx, ticketId, newSale)
|
||||
|
@ -40,5 +38,8 @@ describe('Claim createFromSales()', () => {
|
|||
});
|
||||
|
||||
expect(error.toString()).toContain(`A claim with that sale already exists`);
|
||||
|
||||
// restores
|
||||
await app.models.Claim.destroyById(createdClaimId);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,15 +5,6 @@ describe('Address createAddress', () => {
|
|||
const provinceId = 5;
|
||||
const incotermsId = 'FAS';
|
||||
const customAgentOneId = 1;
|
||||
let address;
|
||||
let client;
|
||||
|
||||
afterAll(async done => {
|
||||
await client.updateAttributes({defaultAddressFk: 1});
|
||||
await address.destroy();
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should throw a non uee member error if no incoterms is defined', async() => {
|
||||
const expectedResult = 'My edited address';
|
||||
|
@ -49,7 +40,6 @@ describe('Address createAddress', () => {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
try {
|
||||
await app.models.Client.createAddress(ctx, clientId);
|
||||
} catch (e) {
|
||||
|
@ -61,7 +51,7 @@ describe('Address createAddress', () => {
|
|||
});
|
||||
|
||||
it('should verify that client defaultAddressFk is untainted', async() => {
|
||||
client = await app.models.Client.findById(clientId);
|
||||
const client = await app.models.Client.findById(clientId);
|
||||
|
||||
expect(client.defaultAddressFk).toEqual(1);
|
||||
});
|
||||
|
@ -79,9 +69,13 @@ describe('Address createAddress', () => {
|
|||
}
|
||||
};
|
||||
|
||||
address = await app.models.Client.createAddress(ctx, clientId);
|
||||
client = await app.models.Client.findById(clientId);
|
||||
const address = await app.models.Client.createAddress(ctx, clientId);
|
||||
const client = await app.models.Client.findById(clientId);
|
||||
|
||||
expect(client.defaultAddressFk).toEqual(address.id);
|
||||
|
||||
// restores
|
||||
await client.updateAttributes({defaultAddressFk: 1});
|
||||
await address.destroy();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,26 +6,11 @@ describe('Address updateAddress', () => {
|
|||
const provinceId = 5;
|
||||
const incotermsId = 'FAS';
|
||||
const customAgentOneId = 1;
|
||||
let oldAddress;
|
||||
let address;
|
||||
|
||||
afterAll(async done => {
|
||||
await address.updateAttributes({
|
||||
nickname: oldAddress.nickname,
|
||||
provinceFk: 1,
|
||||
customsAgentFk: null,
|
||||
incotermsFk: null
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should throw a non uee member error if no incoterms is defined', async() => {
|
||||
const expectedResult = 'My edited address';
|
||||
it('should throw the non uee member error if no incoterms is defined', async() => {
|
||||
const ctx = {
|
||||
args: {
|
||||
provinceFk: provinceId,
|
||||
nickname: expectedResult,
|
||||
customsAgentFk: customAgentOneId
|
||||
}
|
||||
};
|
||||
|
@ -41,16 +26,13 @@ describe('Address updateAddress', () => {
|
|||
});
|
||||
|
||||
it('should throw a non uee member error if no customsAgent is defined', async() => {
|
||||
const expectedResult = 'My edited address';
|
||||
const ctx = {
|
||||
args: {
|
||||
provinceFk: provinceId,
|
||||
nickname: expectedResult,
|
||||
incotermsFk: incotermsId
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
try {
|
||||
await app.models.Client.updateAddress(ctx, clientId, addressId);
|
||||
} catch (e) {
|
||||
|
@ -72,13 +54,21 @@ describe('Address updateAddress', () => {
|
|||
}
|
||||
};
|
||||
|
||||
oldAddress = await app.models.Address.findById(addressId);
|
||||
let oldAddress = await app.models.Address.findById(addressId);
|
||||
|
||||
await app.models.Client.updateAddress(ctx, clientId, addressId);
|
||||
|
||||
address = await app.models.Address.findById(addressId);
|
||||
let address = await app.models.Address.findById(addressId);
|
||||
|
||||
expect(address.nickname).toEqual(expectedResult);
|
||||
|
||||
// restores
|
||||
await address.updateAttributes({
|
||||
nickname: oldAddress.nickname,
|
||||
provinceFk: oldAddress.provinceFk,
|
||||
customsAgentFk: null,
|
||||
incotermsFk: null
|
||||
});
|
||||
});
|
||||
|
||||
it('should update the address', async() => {
|
||||
|
@ -96,5 +86,13 @@ describe('Address updateAddress', () => {
|
|||
address = await app.models.Address.findById(addressId);
|
||||
|
||||
expect(address.nickname).toEqual(expectedResult);
|
||||
|
||||
// restores
|
||||
await address.updateAttributes({
|
||||
nickname: oldAddress.nickname,
|
||||
provinceFk: oldAddress.provinceFk,
|
||||
customsAgentFk: null,
|
||||
incotermsFk: null
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,7 +2,6 @@ const app = require('vn-loopback/server/server');
|
|||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Client createWithInsurance', () => {
|
||||
let classificationId;
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 101},
|
||||
http: {
|
||||
|
@ -16,12 +15,6 @@ describe('Client createWithInsurance', () => {
|
|||
return value;
|
||||
};
|
||||
|
||||
afterAll(async done => {
|
||||
await app.models.CreditClassification.destroyById(classificationId);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should verify the classifications and insurances are untainted', async() => {
|
||||
let classifications = await app.models.CreditClassification.find();
|
||||
let insurances = await app.models.CreditInsurance.find();
|
||||
|
@ -57,8 +50,6 @@ describe('Client createWithInsurance', () => {
|
|||
});
|
||||
let result = await app.models.CreditClassification.createWithInsurance(data, ctx);
|
||||
|
||||
classificationId = result.id;
|
||||
|
||||
expect(result.client).toEqual(101);
|
||||
|
||||
let classifications = await app.models.CreditClassification.find();
|
||||
|
@ -66,5 +57,8 @@ describe('Client createWithInsurance', () => {
|
|||
|
||||
expect(classifications.length).toEqual(6);
|
||||
expect(insurances.length).toEqual(4);
|
||||
|
||||
// restore
|
||||
await app.models.CreditClassification.destroyById(result.id);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('book', {
|
||||
description: 'Book a invoiceOut',
|
||||
description: 'Book an invoiceOut',
|
||||
accessType: 'WRITE',
|
||||
accepts: {
|
||||
arg: 'ref',
|
||||
|
|
|
@ -2,38 +2,31 @@ const app = require('vn-loopback/server/server');
|
|||
|
||||
describe('invoiceOut book()', () => {
|
||||
const invoiceOutId = 5;
|
||||
let bookedDate;
|
||||
let OriginalInvoiceOut;
|
||||
let updatedInvoiceOut;
|
||||
|
||||
afterAll(async done => {
|
||||
updatedInvoiceOut.updateAttributes({
|
||||
booked: OriginalInvoiceOut.booked,
|
||||
hasPdf: OriginalInvoiceOut.hasPdf,
|
||||
amount: OriginalInvoiceOut.amount
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should check that invoice out booked is untainted', async() => {
|
||||
const invoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
||||
|
||||
bookedDate = invoiceOut.booked;
|
||||
|
||||
expect(invoiceOut.booked).toBeDefined();
|
||||
expect(invoiceOut.hasPdf).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should confirm the book property have been updated`, async() => {
|
||||
OriginalInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
||||
let invoiceOutRef = OriginalInvoiceOut.ref;
|
||||
it('should update the booked property', async() => {
|
||||
const originalInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
||||
const bookedDate = originalInvoiceOut.booked;
|
||||
const invoiceOutRef = originalInvoiceOut.ref;
|
||||
|
||||
await app.models.InvoiceOut.book(invoiceOutRef);
|
||||
|
||||
updatedInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
||||
const updatedInvoiceOut = await app.models.InvoiceOut.findById(invoiceOutId);
|
||||
|
||||
expect(updatedInvoiceOut.booked).not.toEqual(bookedDate);
|
||||
expect(updatedInvoiceOut.hasPdf).toBeFalsy();
|
||||
|
||||
// restores
|
||||
await updatedInvoiceOut.updateAttributes({
|
||||
booked: originalInvoiceOut.booked,
|
||||
hasPdf: originalInvoiceOut.hasPdf,
|
||||
amount: originalInvoiceOut.amount
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -39,6 +39,8 @@ describe('order filter()', () => {
|
|||
});
|
||||
|
||||
expect(hasEmptyLines).toBeFalsy();
|
||||
|
||||
ctx.args = {showEmpty: null};
|
||||
});
|
||||
|
||||
it('should return the orders matching the showEmpty on true', async() => {
|
||||
|
@ -50,5 +52,7 @@ describe('order filter()', () => {
|
|||
});
|
||||
|
||||
expect(hasEmptyLines).toBeTruthy();
|
||||
|
||||
ctx.args = {showEmpty: null};
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,7 @@ describe('ticket listSaleTracking()', () => {
|
|||
let filter = {where: {ticketFk: 1}};
|
||||
let result = await app.models.SaleTracking.listSaleTracking(filter);
|
||||
|
||||
expect(result[0].concept).toEqual('Ranged weapon longbow 2m');
|
||||
expect(result.length).toEqual(4);
|
||||
});
|
||||
|
||||
it(`should call the listSaleTracking method and return zero if doesn't have lines`, async() => {
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('ticket-request confirm()', () => {
|
||||
let originalRequest;
|
||||
let createdSaleId;
|
||||
let ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
|
@ -13,18 +11,6 @@ describe('ticket-request confirm()', () => {
|
|||
return value;
|
||||
};
|
||||
|
||||
afterAll(async done => {
|
||||
await originalRequest.updateAttributes(originalRequest);
|
||||
await app.models.Sale.destroyById(createdSaleId);
|
||||
await app.models.Sale.destroyById(addedSale.id);
|
||||
|
||||
await app.models.Item.rawSql(`
|
||||
TRUNCATE TABLE cache.last_buy
|
||||
`);
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it(`should throw an error if the item doesn't exist`, async() => {
|
||||
ctx.args = {itemFk: 999};
|
||||
|
||||
|
@ -62,7 +48,7 @@ describe('ticket-request confirm()', () => {
|
|||
|
||||
it(`should throw if there's a sale id`, async() => {
|
||||
const requestId = 4;
|
||||
const itemId = 2;
|
||||
const itemId = 1;
|
||||
const quantity = 10;
|
||||
|
||||
ctx.args = {
|
||||
|
@ -71,6 +57,18 @@ describe('ticket-request confirm()', () => {
|
|||
quantity: quantity
|
||||
};
|
||||
|
||||
const request = await app.models.TicketRequest.findById(requestId);
|
||||
|
||||
expect(request.saleFk).toBeNull();
|
||||
|
||||
await request.updateAttributes({saleFk: 2});
|
||||
|
||||
ctx.args = {
|
||||
itemFk: itemId,
|
||||
id: requestId,
|
||||
quantity: quantity
|
||||
};
|
||||
|
||||
let error;
|
||||
|
||||
try {
|
||||
|
@ -80,6 +78,9 @@ describe('ticket-request confirm()', () => {
|
|||
}
|
||||
|
||||
expect(error.message).toEqual(`This request already contains a sale`);
|
||||
|
||||
// restores
|
||||
await request.updateAttributes({saleFk: null});
|
||||
});
|
||||
|
||||
it(`should create a new sale for the the request if there's no sale id`, async() => {
|
||||
|
@ -87,7 +88,7 @@ describe('ticket-request confirm()', () => {
|
|||
const itemId = 1;
|
||||
const quantity = 10;
|
||||
|
||||
originalRequest = await app.models.TicketRequest.findById(requestId);
|
||||
const originalRequest = await app.models.TicketRequest.findById(requestId);
|
||||
|
||||
ctx.args = {
|
||||
itemFk: itemId,
|
||||
|
@ -99,11 +100,20 @@ describe('ticket-request confirm()', () => {
|
|||
await request.updateAttributes({saleFk: null});
|
||||
await app.models.TicketRequest.confirm(ctx);
|
||||
|
||||
let updatedRequest = await app.models.TicketRequest.findById(requestId);
|
||||
createdSaleId = updatedRequest.saleFk;
|
||||
const updatedRequest = await app.models.TicketRequest.findById(requestId);
|
||||
const createdSaleId = updatedRequest.saleFk;
|
||||
|
||||
expect(updatedRequest.saleFk).toEqual(createdSaleId);
|
||||
expect(updatedRequest.isOk).toEqual(true);
|
||||
expect(updatedRequest.itemFk).toEqual(itemId);
|
||||
|
||||
// restores
|
||||
await originalRequest.updateAttributes(originalRequest);
|
||||
await app.models.Sale.destroyById(createdSaleId);
|
||||
await app.models.Sale.destroyById(createdSaleId);
|
||||
|
||||
await app.models.Item.rawSql(`
|
||||
TRUNCATE TABLE cache.last_buy
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,90 +13,52 @@ describe('ticket deleteStowaway()', () => {
|
|||
return params.nickname;
|
||||
};
|
||||
|
||||
afterAll(async() => {
|
||||
await app.models.Stowaway.rawSql(
|
||||
`CALL ticketStateUpdate(?, ?)`, [shipId, 'OK']);
|
||||
await app.models.Stowaway.rawSql(
|
||||
`CALL ticketStateUpdate(?, ?)`, [stowawayId, 'FREE']);
|
||||
});
|
||||
|
||||
it('should create an stowaway', async() => {
|
||||
it(`should create an stowaway, delete it and see the states of both stowaway and ship go back to the last states`, async() => {
|
||||
await app.models.Stowaway.rawSql(`
|
||||
INSERT INTO stowaway (id, shipFk) VALUES (?, ?)
|
||||
`, [stowawayId, shipId]);
|
||||
await app.models.Stowaway.rawSql(
|
||||
`CALL ticketStateUpdate(?, ?)`, [shipId, 'BOARDING']);
|
||||
await app.models.Stowaway.rawSql(
|
||||
`CALL ticketStateUpdate(?, ?)`, [stowawayId, 'BOARDING']);
|
||||
|
||||
const stowawayExists = await app.models.Stowaway.count({id: stowawayId, shipFk: shipId});
|
||||
let createdStowaways = await app.models.Stowaway.count({id: stowawayId, shipFk: shipId});
|
||||
|
||||
expect(stowawayExists).toEqual(1);
|
||||
});
|
||||
expect(createdStowaways).toEqual(1);
|
||||
|
||||
it('should confirm that the ship ticket is on "BOARDING" state', async() => {
|
||||
const shipState = await app.models.TicketLastState.findOne({
|
||||
let shipState = await app.models.TicketLastState.findOne({
|
||||
where: {
|
||||
ticketFk: shipId
|
||||
}
|
||||
});
|
||||
let stowawayState = await app.models.TicketLastState.findOne({
|
||||
where: {
|
||||
ticketFk: stowawayId
|
||||
}
|
||||
});
|
||||
|
||||
expect(shipState.name).toEqual('Embarcando');
|
||||
});
|
||||
expect(stowawayState.name).toEqual('Embarcando');
|
||||
|
||||
it('should delete the stowaway from the ship ticket', async() => {
|
||||
await app.models.Ticket.deleteStowaway(ctx, shipId);
|
||||
await app.models.Ticket.deleteStowaway(ctx, stowawayId);
|
||||
|
||||
const stowawayExists = await app.models.Stowaway.count({id: stowawayId, shipFk: shipId});
|
||||
createdStowaways = await app.models.Stowaway.count({id: stowawayId, shipFk: shipId});
|
||||
|
||||
expect(stowawayExists).toEqual(0);
|
||||
});
|
||||
expect(createdStowaways).toEqual(0);
|
||||
|
||||
it('should confirm that the ship ticket is not on "BOARDING" state anymore', async() => {
|
||||
const shipState = await app.models.TicketLastState.findOne({
|
||||
shipState = await app.models.TicketLastState.findOne({
|
||||
where: {
|
||||
ticketFk: shipId
|
||||
}
|
||||
});
|
||||
stowawayState = await app.models.TicketLastState.findOne({
|
||||
where: {
|
||||
ticketFk: stowawayId
|
||||
}
|
||||
});
|
||||
|
||||
expect(shipState.name).toEqual('OK');
|
||||
});
|
||||
|
||||
it('should create again an stowaway', async() => {
|
||||
await app.models.Stowaway.rawSql(`
|
||||
INSERT INTO stowaway (id, shipFk) VALUES (?, ?)
|
||||
`, [shipId, stowawayId]);
|
||||
await app.models.Stowaway.rawSql(
|
||||
`CALL ticketStateUpdate(?, ?)`, [stowawayId, 'BOARDING']);
|
||||
|
||||
const stowawayExists = await app.models.Stowaway.count({id: shipId, shipFk: stowawayId});
|
||||
|
||||
expect(stowawayExists).toEqual(1);
|
||||
});
|
||||
|
||||
it('should confirm that the stowaway ticket is on "BOARDING" state', async() => {
|
||||
const shipState = await app.models.TicketLastState.findOne({
|
||||
where: {
|
||||
ticketFk: stowawayId
|
||||
}
|
||||
});
|
||||
|
||||
expect(shipState.name).toEqual('Embarcando');
|
||||
});
|
||||
|
||||
it('should delete the stowaway from the stowaway ticket', async() => {
|
||||
await app.models.Ticket.deleteStowaway(ctx, stowawayId);
|
||||
|
||||
const stowawayExists = await app.models.Stowaway.count({id: shipId, shipFk: stowawayId});
|
||||
|
||||
expect(stowawayExists).toEqual(0);
|
||||
});
|
||||
|
||||
it('should confirm that the stowaway ticket is not on "BOARDING" state anymore', async() => {
|
||||
const shipState = await app.models.TicketLastState.findOne({
|
||||
where: {
|
||||
ticketFk: stowawayId
|
||||
}
|
||||
});
|
||||
|
||||
expect(shipState.name).toEqual('Libre');
|
||||
expect(stowawayState.name).toEqual('Libre');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue