7863-devToTest_2434 #2852
|
@ -295,20 +295,26 @@ describe('Ticket', () => {
|
|||
describe('onCreateClaimAccepted()', () => {
|
||||
it('should perform a query and call window open', () => {
|
||||
jest.spyOn(controller, 'resetChanges').mockReturnThis();
|
||||
jest.spyOn(controller.$state, 'go').mockReturnThis();
|
||||
jest.spyOn(controller.vnApp, 'getUrl').mockReturnThis();
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: {
|
||||
href: () => {}
|
||||
},
|
||||
});
|
||||
jest.spyOn(controller.window.location, 'href');
|
||||
|
||||
const newEmptySale = {quantity: 10};
|
||||
controller.sales.push(newEmptySale);
|
||||
const firstSale = controller.sales[0];
|
||||
const claimId = 1;
|
||||
firstSale.checked = true;
|
||||
|
||||
const expectedParams = {ticketId: 1, sales: [firstSale]};
|
||||
$httpBackend.expect('POST', `Claims/createFromSales`, expectedParams).respond(200, {id: 1});
|
||||
$httpBackend.expect('POST', `Claims/createFromSales`, expectedParams).respond(200, {id: claimId});
|
||||
controller.onCreateClaimAccepted();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.resetChanges).toHaveBeenCalledWith();
|
||||
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.basicData', {id: 1});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue