From 980ac50ba9b3bc132e70b09b573b251ea89a73ff Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 15 Jun 2022 14:03:58 +0200 Subject: [PATCH] feat: add frontTets --- modules/route/front/tickets/index.spec.js | 45 ++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/modules/route/front/tickets/index.spec.js b/modules/route/front/tickets/index.spec.js index 82647d903..f4a58154e 100644 --- a/modules/route/front/tickets/index.spec.js +++ b/modules/route/front/tickets/index.spec.js @@ -58,9 +58,23 @@ describe('Route', () => { }); }); + describe('setHighestPriority()', () => { + it('should set a ticket highest priority', () => { + jest.spyOn(controller.vnApp, 'showSuccess'); + controller.$.model.data = [{priority: 3}]; + const ticket = {id: 1, priority: 2}; + const res = {data: {priority: 4}}; + + $httpBackend.expectPATCH(`Tickets/${ticket.id}/`).respond(res); + controller.setHighestPriority(ticket); + $httpBackend.flush(); + + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); + }); + }); + describe('setPriority()', () => { it('should set a ticket priority', () => { - jest.spyOn(controller.$.model, 'refresh'); jest.spyOn(controller.vnApp, 'showSuccess'); const ticketId = 1; const priority = 999; @@ -69,6 +83,35 @@ describe('Route', () => { controller.setPriority(ticketId, priority); $httpBackend.flush(); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); + }); + }); + + describe('deletePriority()', () => { + it('should delete priority of all tickets', () => { + jest.spyOn(controller.$.model, 'refresh'); + jest.spyOn(controller.vnApp, 'showSuccess'); + controller.tickets = [{id: 1, checked: true}]; + + $httpBackend.expectPATCH(`Tickets/${controller.tickets[0].id}/`).respond(); + controller.deletePriority(); + $httpBackend.flush(); + + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); + expect(controller.$.model.refresh).toHaveBeenCalledWith(); + }); + }); + + describe('setOrderedPriority()', () => { + it('should set priority of all tickets starting by 1', () => { + jest.spyOn(controller.$.model, 'refresh'); + jest.spyOn(controller.vnApp, 'showSuccess'); + const tickets = [{id: 1, checked: true}]; + + $httpBackend.expectPATCH(`Tickets/${tickets[0].id}/`).respond(); + controller.setOrderedPriority(tickets); + $httpBackend.flush(); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); expect(controller.$.model.refresh).toHaveBeenCalledWith(); });