diff --git a/back/methods/chat/spec/sendCheckingPresence.spec.js b/back/methods/chat/spec/sendCheckingPresence.spec.js index 1523cb1d0..497f4947b 100644 --- a/back/methods/chat/spec/sendCheckingPresence.spec.js +++ b/back/methods/chat/spec/sendCheckingPresence.spec.js @@ -1,55 +1,17 @@ const app = require('vn-loopback/server/server'); describe('chat sendCheckingPresence()', () => { + 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; - 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; + 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 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); - - timeEntry = await app.models.WorkerTimeControl.create({ + 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); }); }); diff --git a/loopback/common/methods/vn-model/specs/crud.spec.js b/loopback/common/methods/vn-model/specs/crud.spec.js index e2d261f98..4aa35c14d 100644 --- a/loopback/common/methods/vn-model/specs/crud.spec.js +++ b/loopback/common/methods/vn-model/specs/crud.spec.js @@ -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); }); }); diff --git a/modules/claim/back/methods/claim/specs/createFromSales.spec.js b/modules/claim/back/methods/claim/specs/createFromSales.spec.js index 5353e640a..e211143f9 100644 --- a/modules/claim/back/methods/claim/specs/createFromSales.spec.js +++ b/modules/claim/back/methods/claim/specs/createFromSales.spec.js @@ -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); }); }); diff --git a/modules/client/back/methods/client/specs/createAddress.spec.js b/modules/client/back/methods/client/specs/createAddress.spec.js index 29f9e145f..8b2d1f5e2 100644 --- a/modules/client/back/methods/client/specs/createAddress.spec.js +++ b/modules/client/back/methods/client/specs/createAddress.spec.js @@ -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(); }); }); diff --git a/modules/client/back/methods/client/specs/updateAddress.spec.js b/modules/client/back/methods/client/specs/updateAddress.spec.js index 7dca0883e..6855d8e18 100644 --- a/modules/client/back/methods/client/specs/updateAddress.spec.js +++ b/modules/client/back/methods/client/specs/updateAddress.spec.js @@ -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 + }); }); }); diff --git a/modules/client/back/methods/credit-classification/createWithInsurance.spec.js b/modules/client/back/methods/credit-classification/createWithInsurance.spec.js index 21abddb81..596c9b140 100644 --- a/modules/client/back/methods/credit-classification/createWithInsurance.spec.js +++ b/modules/client/back/methods/credit-classification/createWithInsurance.spec.js @@ -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); }); }); diff --git a/modules/invoiceOut/back/methods/invoiceOut/book.js b/modules/invoiceOut/back/methods/invoiceOut/book.js index a3a909f2a..358de8fd5 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/book.js +++ b/modules/invoiceOut/back/methods/invoiceOut/book.js @@ -1,7 +1,7 @@ module.exports = Self => { Self.remoteMethod('book', { - description: 'Book a invoiceOut', + description: 'Book an invoiceOut', accessType: 'WRITE', accepts: { arg: 'ref', diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js index 85821773c..0f0a7bade 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/book.spec.js @@ -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 + }); }); }); diff --git a/modules/order/back/methods/order/specs/filter.spec.js b/modules/order/back/methods/order/specs/filter.spec.js index 13cb8fdeb..1e6022ccb 100644 --- a/modules/order/back/methods/order/specs/filter.spec.js +++ b/modules/order/back/methods/order/specs/filter.spec.js @@ -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}; }); }); diff --git a/modules/ticket/back/methods/sale-tracking/listSaleTracking.js b/modules/ticket/back/methods/sale-tracking/listSaleTracking.js index 8d3e0c248..0bcb94c03 100644 --- a/modules/ticket/back/methods/sale-tracking/listSaleTracking.js +++ b/modules/ticket/back/methods/sale-tracking/listSaleTracking.js @@ -22,22 +22,22 @@ module.exports = Self => { Self.listSaleTracking = async filter => { let stmt = new ParameterizedSQL(` - SELECT - st.id, - s.ticketFk, - s.quantity, - s.concept, - s.itemFk, - st.originalQuantity, - st.created, - st.workerFk, - u.nickname userNickname, - ste.name AS state - FROM saleTracking st - JOIN sale s ON s.id = st.saleFk - JOIN worker w ON w.id = st.workerFk - JOIN account.user u ON u.id = w.userFk - JOIN state ste ON ste.id = st.stateFk`); + SELECT + st.id, + s.ticketFk, + s.quantity, + s.concept, + s.itemFk, + st.originalQuantity, + st.created, + st.workerFk, + u.nickname userNickname, + ste.name AS state + FROM saleTracking st + JOIN sale s ON s.id = st.saleFk + JOIN worker w ON w.id = st.workerFk + JOIN account.user u ON u.id = w.userFk + JOIN state ste ON ste.id = st.stateFk`); stmt.merge(Self.makeSuffix(filter)); diff --git a/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js b/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js index 0d9937f89..7b19f45bb 100644 --- a/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js +++ b/modules/ticket/back/methods/sale-tracking/specs/listSaleTracking.spec.js @@ -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() => { diff --git a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js index 5d902ae5d..e87c0c10a 100644 --- a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js @@ -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 + `); }); }); diff --git a/modules/ticket/back/methods/ticket/specs/deleteStowaway.spec.js b/modules/ticket/back/methods/ticket/specs/deleteStowaway.spec.js index 56375940d..563c1334d 100644 --- a/modules/ticket/back/methods/ticket/specs/deleteStowaway.spec.js +++ b/modules/ticket/back/methods/ticket/specs/deleteStowaway.spec.js @@ -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'); }); });