feat: add frontTets
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-06-15 14:03:58 +02:00
parent f69fb45b90
commit 980ac50ba9
1 changed files with 44 additions and 1 deletions

View File

@ -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();
});