update volume is not called when add/remove tickets from route
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
790c3729aa
commit
320c04b2d3
|
@ -133,7 +133,7 @@ describe('Component vnRouteIndex', () => {
|
|||
});
|
||||
|
||||
describe('insert()', () => {
|
||||
it('should make a HTTP patch query and then call both refresh and showSuccess methods', () => {
|
||||
it('should perform a HTTP patch query and then call both refresh and showSuccess methods', () => {
|
||||
jest.spyOn(controller.$.model, 'refresh').mockReturnThis();
|
||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||
|
||||
|
|
|
@ -131,6 +131,7 @@ class Controller extends Section {
|
|||
.then(() => {
|
||||
this.$.model.data = this.$.model.data.concat(tickets);
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.updateVolume();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -157,8 +158,7 @@ class Controller extends Section {
|
|||
const query = `Routes/${this.route.id}/insertTicket`;
|
||||
return this.$http.patch(query, {ticketId}).then(() => {
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.$.model.refresh();
|
||||
this.card.reload();
|
||||
this.updateVolume();
|
||||
}).catch(error => {
|
||||
if (error.status == 404)
|
||||
return this.vnApp.showError(this.$t('Ticket not found'));
|
||||
|
|
|
@ -129,19 +129,20 @@ describe('Route', () => {
|
|||
|
||||
describe('removeTicketFromRoute()', () => {
|
||||
it('should perform a patch query then call showSuccess and updateVolume methods', () => {
|
||||
jest.spyOn(controller, 'updateVolume').mockReturnThis();
|
||||
controller.$params = {id: 1101};
|
||||
|
||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||
jest.spyOn(controller.$.model, 'remove');
|
||||
|
||||
let ticketId = 1;
|
||||
controller.selectedTicket = ticketId;
|
||||
|
||||
$httpBackend.whenPOST(`Routes/${controller.$params.id}/updateVolume`).respond(200);
|
||||
$httpBackend.expectPATCH(`Tickets/${ticketId}/`).respond('ok');
|
||||
controller.removeTicketFromRoute();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Ticket removed from route');
|
||||
expect(controller.updateVolume).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -196,9 +197,8 @@ describe('Route', () => {
|
|||
|
||||
describe('setTicketsRoute()', () => {
|
||||
it('should perform a POST query to add tickets to the route', () => {
|
||||
controller.$.model = {data: [
|
||||
{id: 1, checked: false}
|
||||
]};
|
||||
controller.$params = {id: 1101};
|
||||
controller.$.model.data = [{id: 1, checked: false}];
|
||||
|
||||
const existingTicket = controller.$.model.data[0];
|
||||
|
||||
|
@ -217,7 +217,8 @@ describe('Route', () => {
|
|||
{id: 5}
|
||||
];
|
||||
|
||||
$httpBackend.expectPOST(`Tickets/crud`).respond();
|
||||
$httpBackend.whenPOST(`Routes/${controller.$params.id}/updateVolume`).respond(200);
|
||||
$httpBackend.expectPOST('Tickets/crud').respond();
|
||||
controller.setTicketsRoute();
|
||||
$httpBackend.flush();
|
||||
|
||||
|
@ -273,11 +274,15 @@ describe('Route', () => {
|
|||
|
||||
describe('insert()', () => {
|
||||
it('should make a HTTP patch query and then call both refresh and showSuccess methods', () => {
|
||||
controller.$params = {id: 1101};
|
||||
|
||||
jest.spyOn(controller.$.model, 'refresh').mockReturnThis();
|
||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||
|
||||
const ticketId = 11;
|
||||
const data = {ticketId};
|
||||
|
||||
$httpBackend.whenPOST(`Routes/${controller.$params.id}/updateVolume`).respond(200);
|
||||
$httpBackend.expect('PATCH', `Routes/1/insertTicket`, data).respond();
|
||||
controller.insert(ticketId);
|
||||
$httpBackend.flush();
|
||||
|
|
Loading…
Reference in New Issue