action test updated
This commit is contained in:
parent
03c6aef542
commit
04a452bd82
|
@ -19,7 +19,7 @@ describe('claim', () => {
|
|||
$state = _$state_;
|
||||
$state.params.id = 1;
|
||||
|
||||
controller = $componentController('vnClaimDetail', {$state: $state});
|
||||
controller = $componentController('vnClaimAction', {$state: $state});
|
||||
controller.claim = {ticketFk: 1};
|
||||
controller.$.model = {refresh: () => {}};
|
||||
controller.$.addSales = {
|
||||
|
@ -31,22 +31,23 @@ describe('claim', () => {
|
|||
describe('openAddSalesDialog()', () => {
|
||||
it('should call getClaimableFromTicket and $.addSales.show', () => {
|
||||
controller.$ = {addSales: {show: () => {}}};
|
||||
spyOn(controller, 'getClaimableFromTicket');
|
||||
spyOn(controller, 'getClaimedSales');
|
||||
spyOn(controller.$.addSales, 'show');
|
||||
controller.openAddSalesDialog();
|
||||
|
||||
expect(controller.getClaimableFromTicket).toHaveBeenCalledWith();
|
||||
expect(controller.getClaimedSales).toHaveBeenCalledWith();
|
||||
expect(controller.$.addSales.show).toHaveBeenCalledWith();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getClaimableFromTicket()', () => {
|
||||
describe('getClaimedSales()', () => {
|
||||
it('should make a query and set salesToClaim', () => {
|
||||
$httpBackend.expectGET(`/api/Sales/getClaimableFromTicket?ticketFk=1`).respond(200, 1);
|
||||
controller.getClaimableFromTicket();
|
||||
controller.claim.id = 1;
|
||||
$httpBackend.expectGET(`/claim/api/ClaimBeginnings/1`).respond(200, 1);
|
||||
controller.getClaimedSales();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.salesToClaim).toEqual(1);
|
||||
expect(controller.claimedSales).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -55,7 +56,7 @@ describe('claim', () => {
|
|||
spyOn(controller.$.model, 'refresh');
|
||||
spyOn(controller.$.addSales, 'hide');
|
||||
spyOn(controller.vnApp, 'showSuccess');
|
||||
$httpBackend.expectPOST(`claim/api/ClaimBeginnings/`).respond({});
|
||||
$httpBackend.expectPOST(`claim/api/ClaimEnds/`).respond({});
|
||||
controller.addClaimedSale(1);
|
||||
$httpBackend.flush();
|
||||
|
||||
|
@ -69,7 +70,7 @@ describe('claim', () => {
|
|||
it('should make a delete and call refresh and showSuccess', () => {
|
||||
spyOn(controller.$.model, 'refresh');
|
||||
spyOn(controller.vnApp, 'showSuccess');
|
||||
$httpBackend.expectDELETE(`claim/api/ClaimBeginnings/1`).respond({});
|
||||
$httpBackend.expectDELETE(`claim/api/ClaimEnds/1`).respond({});
|
||||
controller.deleteClaimedSale(1);
|
||||
$httpBackend.flush();
|
||||
|
||||
|
@ -78,17 +79,30 @@ describe('claim', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('setClaimedQuantity(id, claimedQuantity)', () => {
|
||||
describe('setClaimDestination(id, claimDestinationFk)', () => {
|
||||
it('should make a patch and call refresh and showSuccess', () => {
|
||||
spyOn(controller.$.model, 'refresh');
|
||||
spyOn(controller.vnApp, 'showSuccess');
|
||||
$httpBackend.expectPATCH(`claim/api/ClaimBeginnings/`).respond({});
|
||||
controller.setClaimedQuantity(1, 1);
|
||||
$httpBackend.expectPATCH(`claim/api/ClaimEnds/`).respond({});
|
||||
controller.setClaimDestination(1, 1);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
||||
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
||||
});
|
||||
});
|
||||
|
||||
describe('calculateTotals()', () => {
|
||||
it('should calculate the total price of the items claimed', () => {
|
||||
controller.salesClaimed = [
|
||||
{sale: {quantity: 5, price: 2, discount: 0}},
|
||||
{sale: {quantity: 10, price: 2, discount: 0}},
|
||||
{sale: {quantity: 10, price: 2, discount: 0}}
|
||||
];
|
||||
controller.calculateTotals();
|
||||
|
||||
expect(controller.claimedTotal).toEqual(50);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue