8713-testToMaster #1539
|
@ -27,14 +27,17 @@ describe('getAgencies', () => {
|
||||||
landed: 'true',
|
landed: 'true',
|
||||||
};
|
};
|
||||||
const filter = {
|
const filter = {
|
||||||
fields: ['nickname', 'street', 'city', 'id'],
|
fields: ['name', 'street', 'city', 'id'],
|
||||||
where: { isActive: true },
|
where: { isActive: true },
|
||||||
order: 'nickname ASC',
|
order: ['name ASC'],
|
||||||
};
|
};
|
||||||
|
|
||||||
await getAgencies(formData, null, filter);
|
await getAgencies(formData, null, filter);
|
||||||
|
|
||||||
expect(axios.get).toHaveBeenCalledWith('Agencies/getAgenciesWithWarehouse', generateParams(formData, filter));
|
expect(axios.get).toHaveBeenCalledWith(
|
||||||
|
'Agencies/getAgenciesWithWarehouse',
|
||||||
|
generateParams(formData, filter),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not call API when formData is missing required landed field', async () => {
|
it('should not call API when formData is missing required landed field', async () => {
|
||||||
|
@ -64,19 +67,19 @@ describe('getAgencies', () => {
|
||||||
it('should return options and agency when default agency is found', async () => {
|
it('should return options and agency when default agency is found', async () => {
|
||||||
const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
|
const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
|
||||||
const client = { defaultAddress: { agencyModeFk: 'Agency1' } };
|
const client = { defaultAddress: { agencyModeFk: 'Agency1' } };
|
||||||
|
|
||||||
const { options, agency } = await getAgencies(formData, client);
|
const { options, agency } = await getAgencies(formData, client);
|
||||||
|
|
||||||
expect(options).toEqual(response.data);
|
expect(options).toEqual(response.data);
|
||||||
expect(agency).toEqual(response.data[0]);
|
expect(agency).toEqual(response.data[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return options and agency when client is not provided', async () => {
|
it('should return options and agency when client is not provided', async () => {
|
||||||
const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
|
const formData = { warehouseId: '123', addressId: '456', landed: 'true' };
|
||||||
|
|
||||||
const { options, agency } = await getAgencies(formData);
|
const { options, agency } = await getAgencies(formData);
|
||||||
|
|
||||||
expect(options).toEqual(response.data);
|
expect(options).toEqual(response.data);
|
||||||
expect(agency).toBeNull();
|
expect(agency).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,8 +4,8 @@ export async function getAgencies(formData, client, _filter = {}) {
|
||||||
if (!formData.warehouseId || !formData.addressId || !formData.landed) return;
|
if (!formData.warehouseId || !formData.addressId || !formData.landed) return;
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
order: ['name ASC'],
|
|
||||||
..._filter,
|
..._filter,
|
||||||
|
order: ['name ASC'],
|
||||||
};
|
};
|
||||||
|
|
||||||
let defaultAgency = null;
|
let defaultAgency = null;
|
||||||
|
|
Loading…
Reference in New Issue