3491-ticket_volume #847

Merged
carlosjr merged 5 commits from 3491-ticket_volume into dev 2022-01-17 13:02:16 +00:00
1 changed files with 31 additions and 12 deletions
Showing only changes of commit c9564e817a - Show all commits

View File

@ -33,17 +33,20 @@ describe('ticket', () => {
});
});
describe('volumes() setter', () => {
it('should set volumes property on controller an then call applyVolumes() method', () => {
jest.spyOn(controller, 'applyVolumes');
controller.volumes = [{id: 1}];
expect(controller.applyVolumes).toHaveBeenCalledWith();
});
});
describe('applyVolumes()', () => {
const ticket = 1;
const respondGet =
{
saleVolume: [
{saleFk: 1, volume: 0.012},
{saleFk: 2, volume: 0.015}
],
packingTypeVolume: [
{code: 'V', volume: 1},
{code: 'H',volume: 2},
]
};
it(`should not apply volumes to the sales if sales property is not defined on controller`, () => {
controller.sales = [{id: 1, name: 'Sale one'}, {id: 2, name: 'Sale two'}];
@ -58,12 +61,28 @@ describe('ticket', () => {
});
it(`should apply volumes to the sales if sales and volumes properties are defined on controller`, () => {
controller.sales = [{id: 1, name: 'Sale one'}, {id: 2, name: 'Sale two'}];
controller.volumes = [{saleFk: 1, volume: 0.012}, {saleFk: 2, volume: 0.015}];
$httpBackend.expectGET(`Tickets/${ticket}/getVolume`).respond(respondGet);
controller.sales = [
{id: 1, name: 'Sale one', ticketFk: ticket},
{id: 2, name: 'Sale two'}
];
$httpBackend.flush();
expect(controller.sales[0].saleVolume.volume).toEqual(0.012);
expect(controller.sales[1].saleVolume.volume).toEqual(0.015);
});
it(`should apply packing volumes to the sales if sales and volumes properties are defined on controller`, () => {
$httpBackend.expectGET(`Tickets/${ticket}/getVolume`).respond(respondGet);
controller.sales = [
{id: 1, name: 'Sale one', ticketFk: ticket},
{id: 2, name: 'Sale two'}
];
$httpBackend.flush();
expect(controller.packingTypeVolume[0]).toBeDefined;
expect(controller.packingTypeVolume[1]).toBeDefined
});
});
/*