Removed test exclusion
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-10-06 14:32:24 +02:00
parent 2856fa63fc
commit 254c391138
3 changed files with 36 additions and 26 deletions

View File

@ -127,7 +127,7 @@ export default class Controller extends Section {
promises.push(this.getGreugeConfig());
return Promise.all(promises).then(() => {
const data = {
return this.updateGreuge({
clientFk: this.claim.clientFk,
description: this.$t('ClaimGreugeDescription', {
claimId: this.claim.id
@ -135,14 +135,17 @@ export default class Controller extends Section {
amount: this.freightPickUpPrice,
greugeTypeFk: this.greugeTypeFreightId,
ticketFk: this.claim.ticketFk
};
return this.$http.post(`Greuges`, data).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.vnApp.showMessage(this.$t('Greuge inserted'));
});
});
}
updateGreuge(data) {
return this.$http.post(`Greuges`, data).then(() => {
this.vnApp.showSuccess(this.$t('Data saved!'));
this.vnApp.showMessage(this.$t('Greuge added'));
});
}
save(data) {
const query = `Claims/${this.$params.id}/updateClaimAction`;
this.$http.patch(query, data)

View File

@ -128,9 +128,6 @@ describe('claim', () => {
const freightPickUpPrice = 11;
it('should make a query and get the greugeTypeId and greuge config', () => {
jest.spyOn(controller.card, 'reload');
jest.spyOn(controller.vnApp, 'showSuccess');
$httpBackend.expectRoute('GET', `GreugeTypes/findOne`).respond({id: greugeTypeId});
$httpBackend.expectGET(`GreugeConfigs/findOne`).respond({freightPickUpPrice});
controller.onUpdateGreugeAccept();
@ -140,37 +137,47 @@ describe('claim', () => {
expect(controller.freightPickUpPrice).toEqual(freightPickUpPrice);
});
// #1957 - Investigate how to test nested httpBackend requests
xit('should perform a insert into greuges', () => {
jest.spyOn(controller.card, 'reload');
jest.spyOn(controller.vnApp, 'showSuccess');
jest.spyOn(controller, 'getGreugeTypeId').and.returnValue(new Promise(resolve => {
it('should perform a insert into greuges', done => {
jest.spyOn(controller, 'getGreugeTypeId').mockReturnValue(new Promise(resolve => {
return resolve({id: greugeTypeId});
}));
jest.spyOn(controller, 'getGreugeConfig').and.returnValue(new Promise(resolve => {
jest.spyOn(controller, 'getGreugeConfig').mockReturnValue(new Promise(resolve => {
return resolve({freightPickUpPrice});
}));
jest.spyOn(controller, 'updateGreuge').mockReturnValue(new Promise(resolve => {
return resolve(true);
}));
controller.claim.clientFk = 101;
controller.claim.id = 11;
let data = {
controller.onUpdateGreugeAccept().then(() => {
expect(controller.updateGreuge).toHaveBeenCalledWith(jasmine.any(Object));
done();
}).catch(done.fail);
});
});
describe('updateGreuge()', () => {
it('should make a query and then show an snackbar', () => {
jest.spyOn(controller.vnApp, 'showSuccess');
jest.spyOn(controller.vnApp, 'showMessage');
const freightPickUpPrice = 11;
const greugeTypeId = 7;
const expectedData = {
clientFk: 101,
description: `claim: ${controller.claim.id}`,
amount: freightPickUpPrice,
greugeTypeFk: greugeTypeId,
ticketFk: controller.claim.ticketFk
};
$httpBackend.expect('POST', `Greuges/`, data).respond(new Promise(resolve => {
return resolve({id: freightPickUpPrice});
}));
controller.onUpdateGreugeAccept().then(res => {
}).catch(error => {
});
$httpBackend.expect('POST', `Greuges`, expectedData).respond(200);
controller.updateGreuge(expectedData);
$httpBackend.flush();
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Greuge added');
});
});
});

View File

@ -8,5 +8,5 @@ Imports ticket lines: Importa las lineas de un ticket
Regularize: Regularizar
Do you want to insert greuges?: Desea insertar greuges?
Insert greuges on client card: Insertar greuges en la ficha del cliente
Greuge inserted: Greuge insertado
Greuge added: Greuge añadido
ClaimGreugeDescription: Reclamación id {{claimId}}