test(ticket_volume): frontTest
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
fba09e8c40
commit
c9564e817a
|
@ -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
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue