ticket.basicData address
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
f168734b8c
commit
666ccbf370
|
@ -22,7 +22,7 @@ class Controller {
|
|||
|
||||
if (!value || !value.id) return;
|
||||
|
||||
this.onChangeClient(value.clientFk);
|
||||
this.clientAddressesList(value.clientFk);
|
||||
}
|
||||
|
||||
get clientId() {
|
||||
|
@ -33,7 +33,8 @@ class Controller {
|
|||
this.ticket.clientFk = value;
|
||||
this.ticket.addressFk = null;
|
||||
|
||||
this.onChangeClient(value);
|
||||
this.getClientDefaultAddress(value);
|
||||
this.clientAddressesList(value);
|
||||
}
|
||||
|
||||
get addressId() {
|
||||
|
@ -68,7 +69,6 @@ class Controller {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
get shipped() {
|
||||
return this.ticket && this.ticket.shipped;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class Controller {
|
|||
/*
|
||||
* Autocompletes address on client change
|
||||
*/
|
||||
onChangeClient(value) {
|
||||
clientAddressesList(value) {
|
||||
let filter = {
|
||||
include: [
|
||||
{
|
||||
|
@ -153,6 +153,14 @@ class Controller {
|
|||
});
|
||||
}
|
||||
|
||||
getClientDefaultAddress(value) {
|
||||
let query = `Clients/${value}`;
|
||||
this.$http.get(query).then(res => {
|
||||
if (res.data)
|
||||
this.ticket.addressFk = res.data.defaultAddressFk;
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets an agency from an specified zone
|
||||
*/
|
||||
|
|
|
@ -22,18 +22,18 @@ describe('Ticket', () => {
|
|||
}));
|
||||
|
||||
describe('ticket() setter', () => {
|
||||
it('should set ticket property and call onChangeClient() method', () => {
|
||||
jest.spyOn(controller, 'onChangeClient');
|
||||
it('should set ticket property and call clientAddressesList() method', () => {
|
||||
jest.spyOn(controller, 'clientAddressesList');
|
||||
controller.ticket = {id: 1, clientFk: 101};
|
||||
|
||||
expect(controller.onChangeClient).toHaveBeenCalledWith(101);
|
||||
expect(controller.clientAddressesList).toHaveBeenCalledWith(101);
|
||||
});
|
||||
|
||||
it(`should not call onChangeClient() method as the ticket doesn't have an ID`, () => {
|
||||
jest.spyOn(controller, 'onChangeClient');
|
||||
it(`should not call clientAddressesList() method as the ticket doesn't have an ID`, () => {
|
||||
jest.spyOn(controller, 'clientAddressesList');
|
||||
controller.ticket = {};
|
||||
|
||||
expect(controller.onChangeClient).not.toHaveBeenCalledWith();
|
||||
expect(controller.clientAddressesList).not.toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -46,12 +46,12 @@ describe('Ticket', () => {
|
|||
});
|
||||
|
||||
describe('clientId() setter', () => {
|
||||
it('should set clientId property and call onChangeClient() method ', () => {
|
||||
jest.spyOn(controller, 'onChangeClient');
|
||||
it('should set clientId property and call clientAddressesList() method ', () => {
|
||||
jest.spyOn(controller, 'clientAddressesList');
|
||||
controller.ticket = {id: 1, clientId: 101};
|
||||
controller.clientId = 102;
|
||||
|
||||
expect(controller.onChangeClient).toHaveBeenCalledWith(102);
|
||||
expect(controller.clientAddressesList).toHaveBeenCalledWith(102);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -155,7 +155,6 @@ describe('Ticket', () => {
|
|||
};
|
||||
controller.landed = landed;
|
||||
|
||||
|
||||
expect(controller.getShipped).toHaveBeenCalledWith(expectedResult);
|
||||
});
|
||||
});
|
||||
|
@ -230,7 +229,7 @@ describe('Ticket', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('onChangeClient()', () => {
|
||||
describe('clientAddressesList()', () => {
|
||||
it('should return a list of addresses from choosed client', async() => {
|
||||
const clientId = 102;
|
||||
let filter = {
|
||||
|
@ -253,7 +252,18 @@ describe('Ticket', () => {
|
|||
|
||||
$httpBackend.when('GET', `Clients/${clientId}/addresses?filter=${filter}`).respond(200);
|
||||
$httpBackend.expect('GET', `Clients/${clientId}/addresses?filter=${filter}`);
|
||||
controller.onChangeClient(clientId);
|
||||
controller.clientAddressesList(clientId);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getClientDefaultAddress()', () => {
|
||||
it('should return the default address from choosed client', async() => {
|
||||
const clientId = 102;
|
||||
|
||||
$httpBackend.when('GET', `Clients/${clientId}`).respond(200);
|
||||
$httpBackend.expect('GET', `Clients/${clientId}`);
|
||||
controller.getClientDefaultAddress(clientId);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue