feat(ticket_sale): add front test
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-03-29 13:42:56 +02:00
parent a5ca116571
commit c15aea213f
1 changed files with 28 additions and 2 deletions

View File

@ -43,7 +43,7 @@ describe('Ticket', () => {
$scope.sms = {open: () => {}};
$scope.ticket = ticket;
$scope.model = crudModel;
$scope.editDiscount = {relocate: () => {}};
$scope.editDiscount = {relocate: () => {}, hide: () => {}};
$scope.editPricePopover = {relocate: () => {}};
$httpBackend = _$httpBackend_;
Object.defineProperties($state.params, {
@ -63,6 +63,14 @@ describe('Ticket', () => {
controller._sales = sales;
}));
describe('manaType() setter/getter', () => {
it('should set the manaType data', () => {
controller.manaType = 'mana claim';
expect(controller.manaType).toEqual('mana claim');
});
});
describe('ticket() setter', () => {
it('should set the ticket data an then call the isTicketEditable() and isTicketLocked() methods', () => {
jest.spyOn(controller, 'isTicketEditable').mockReturnThis();
@ -446,7 +454,7 @@ describe('Ticket', () => {
const expectedSales = [firstSelectedSale, secondSelectedSale];
const expectedSaleIds = [firstSelectedSale.id, secondSelectedSale.id];
const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount};
const expectedParams = {salesIds: expectedSaleIds, newDiscount: expectedDiscount, manaType: 'mana'};
$httpBackend.expect('POST', `Tickets/1/updateDiscount`, expectedParams).respond(200, {discount: 10});
controller.updateDiscount(expectedSales);
$httpBackend.flush();
@ -732,5 +740,23 @@ describe('Ticket', () => {
expect(result).toEqual({name: {like: '%' + itemName + '%'}});
});
});
describe('save()', () => {
it('should call changeDiscount()', () => {
jest.spyOn(controller, 'changeDiscount').mockReturnThis();
controller.save();
expect(controller.changeDiscount).toHaveBeenCalledWith();
});
});
describe('cancel()', () => {
it('should call hide()', () => {
jest.spyOn(controller.$.editDiscount, 'hide').mockReturnThis();
controller.cancel();
expect(controller.$.editDiscount.hide).toHaveBeenCalledWith();
});
});
});
});