2019-06-06 07:34:36 +00:00
|
|
|
import '../index.js';
|
2019-09-05 07:00:55 +00:00
|
|
|
import watcher from 'core/mocks/watcher';
|
2019-11-14 13:19:39 +00:00
|
|
|
import crudModel from 'core/mocks/crud-model';
|
2018-05-08 07:25:15 +00:00
|
|
|
|
2019-09-30 09:30:54 +00:00
|
|
|
describe('Ticket', () => {
|
2018-05-08 07:25:15 +00:00
|
|
|
describe('Component vnTicketSale', () => {
|
2018-11-06 13:27:16 +00:00
|
|
|
let controller;
|
2018-05-08 07:25:15 +00:00
|
|
|
let $scope;
|
2019-09-13 14:09:14 +00:00
|
|
|
let $state;
|
2018-10-22 06:23:10 +00:00
|
|
|
let $httpBackend;
|
|
|
|
|
2019-09-13 14:09:14 +00:00
|
|
|
const ticket = {
|
2018-10-22 06:23:10 +00:00
|
|
|
id: 1,
|
2019-08-09 06:04:44 +00:00
|
|
|
clientFk: 101,
|
2018-10-22 06:23:10 +00:00
|
|
|
shipped: 1,
|
2019-03-29 06:29:09 +00:00
|
|
|
created: new Date(),
|
|
|
|
client: {salesPersonFk: 1},
|
|
|
|
address: {mobile: 111111111}
|
2018-10-22 06:23:10 +00:00
|
|
|
};
|
2019-09-13 14:09:14 +00:00
|
|
|
const sales = [
|
2018-10-22 06:23:10 +00:00
|
|
|
{
|
|
|
|
id: 1,
|
2019-03-29 06:29:09 +00:00
|
|
|
concept: 'Item 1',
|
2018-10-22 06:23:10 +00:00
|
|
|
quantity: 5,
|
|
|
|
price: 23.5,
|
2019-09-13 14:09:14 +00:00
|
|
|
discount: 0,
|
2018-10-22 06:23:10 +00:00
|
|
|
}, {
|
|
|
|
id: 4,
|
2019-03-29 06:29:09 +00:00
|
|
|
concept: 'Item 2',
|
2018-10-22 06:23:10 +00:00
|
|
|
quantity: 20,
|
|
|
|
price: 5.5,
|
2019-09-13 14:09:14 +00:00
|
|
|
discount: 0,
|
2018-10-22 06:23:10 +00:00
|
|
|
}
|
|
|
|
];
|
2018-05-08 07:25:15 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('ticket'));
|
2018-10-22 06:23:10 +00:00
|
|
|
|
2019-09-13 14:09:14 +00:00
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_, _$httpBackend_) => {
|
|
|
|
$state = _$state_;
|
2018-05-08 07:25:15 +00:00
|
|
|
$scope = $rootScope.$new();
|
2019-09-05 07:00:55 +00:00
|
|
|
$scope.watcher = watcher;
|
2019-09-13 14:09:14 +00:00
|
|
|
$scope.sms = {open: () => {}};
|
|
|
|
$scope.ticket = ticket;
|
2019-11-14 13:19:39 +00:00
|
|
|
$scope.model = crudModel;
|
2018-10-22 06:23:10 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2019-09-13 14:09:14 +00:00
|
|
|
Object.defineProperties($state.params, {
|
|
|
|
id: {
|
|
|
|
value: ticket.id,
|
|
|
|
writable: true
|
|
|
|
},
|
|
|
|
go: {
|
|
|
|
value: () => {},
|
|
|
|
writable: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
controller = $componentController('vnTicketSale', {$scope, $state});
|
2018-11-06 13:27:16 +00:00
|
|
|
controller.card = {reload: () => {}};
|
2019-09-13 14:09:14 +00:00
|
|
|
controller.ticket = ticket;
|
|
|
|
controller.sales = sales;
|
2018-05-08 07:25:15 +00:00
|
|
|
}));
|
|
|
|
|
2018-09-11 10:49:31 +00:00
|
|
|
describe('createClaim()', () => {
|
2018-10-22 06:23:10 +00:00
|
|
|
it('should perform a query and call windows open', () => {
|
2018-11-06 13:27:16 +00:00
|
|
|
spyOn(controller.$state, 'go');
|
2018-10-22 06:23:10 +00:00
|
|
|
|
2019-07-02 10:12:15 +00:00
|
|
|
const claim = {id: 1};
|
|
|
|
const sales = [{id: 1}, {id: 2}];
|
2019-09-13 14:09:14 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
|
|
|
$httpBackend.when('POST', `Claims/createFromSales`, {claim: claim, sales: sales}).respond(claim);
|
|
|
|
$httpBackend.expect('POST', `Claims/createFromSales`).respond(claim);
|
2018-11-06 13:27:16 +00:00
|
|
|
controller.createClaim();
|
2018-09-11 10:49:31 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
2019-02-21 07:43:04 +00:00
|
|
|
expect(controller.subtotal).toEqual(227.5);
|
2018-11-06 13:27:16 +00:00
|
|
|
expect(controller.VAT).toEqual(10.5);
|
|
|
|
expect(controller.total).toEqual(238);
|
2019-09-13 14:09:14 +00:00
|
|
|
expect(controller.$state.go).toHaveBeenCalledWith('claim.card.basicData', {id: 1});
|
2018-07-13 13:57:19 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-10-22 06:23:10 +00:00
|
|
|
describe('isChecked() getter', () => {
|
2018-05-08 07:54:14 +00:00
|
|
|
it('should set isChecked value to true when one of the instances has the value checked to true', () => {
|
2018-11-06 13:27:16 +00:00
|
|
|
controller.sales[0].checked = true;
|
2018-05-08 07:54:14 +00:00
|
|
|
|
2018-11-06 13:27:16 +00:00
|
|
|
expect(controller.isChecked).toBeTruthy();
|
2018-05-08 07:54:14 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-08-09 06:04:44 +00:00
|
|
|
describe('checkedLines()', () => {
|
2018-07-13 13:57:19 +00:00
|
|
|
it('should make an array of the instances with the property checked true()', () => {
|
2019-09-13 14:09:14 +00:00
|
|
|
let sale = controller.sales[0];
|
2018-10-22 06:23:10 +00:00
|
|
|
sale.checked = true;
|
2019-07-02 10:12:15 +00:00
|
|
|
let expectedResult = [sale];
|
2018-07-13 13:57:19 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
2019-09-13 14:09:14 +00:00
|
|
|
let result = controller.checkedLines();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(result).toEqual(expectedResult);
|
2018-07-13 13:57:19 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-05-08 07:25:15 +00:00
|
|
|
describe('onStateOkClick()', () => {
|
|
|
|
it('should perform a get and then call a function', () => {
|
2018-11-06 13:27:16 +00:00
|
|
|
let filter = {where: {code: 'OK'}, fields: ['id']};
|
2018-05-08 07:25:15 +00:00
|
|
|
filter = encodeURIComponent(JSON.stringify(filter));
|
|
|
|
let res = [{id: 3}];
|
2018-11-06 13:27:16 +00:00
|
|
|
spyOn(controller, 'onStateChange');
|
2018-05-08 07:25:15 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.whenGET(`States?filter=${filter}`).respond(res);
|
|
|
|
$httpBackend.expectGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.expectGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
2018-11-06 13:27:16 +00:00
|
|
|
controller.onStateOkClick();
|
2018-05-08 07:25:15 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
2018-11-06 13:27:16 +00:00
|
|
|
expect(controller.onStateChange).toHaveBeenCalledWith(3);
|
2018-05-08 07:25:15 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('onStateChange()', () => {
|
2018-08-02 08:54:03 +00:00
|
|
|
it('should perform a post and then call a function', () => {
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.expectPOST(`TicketTrackings/changeState`).respond();
|
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
2018-11-06 13:27:16 +00:00
|
|
|
controller.onStateChange(3);
|
2018-05-08 07:25:15 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
});
|
|
|
|
});
|
2018-05-08 07:54:14 +00:00
|
|
|
|
2018-09-18 07:52:50 +00:00
|
|
|
describe('onRemoveLinesClick()', () => {
|
2018-07-03 13:23:10 +00:00
|
|
|
it('should call getCheckedLines, call removeInstances, and make a query', () => {
|
2019-09-13 14:09:14 +00:00
|
|
|
controller.sales[0].checked = true;
|
2018-07-03 13:23:10 +00:00
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.whenPOST(`Sales/removes`).respond();
|
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
2019-10-30 15:57:14 +00:00
|
|
|
controller.onRemoveLinesClick('accept');
|
2018-07-03 13:23:10 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
2018-11-06 13:27:16 +00:00
|
|
|
expect(controller.sales.length).toEqual(1);
|
2018-07-03 13:23:10 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('unmarkAsReserved()', () => {
|
|
|
|
it('should call setReserved with false', () => {
|
2018-11-06 13:27:16 +00:00
|
|
|
spyOn(controller, 'setReserved');
|
2018-07-03 13:23:10 +00:00
|
|
|
|
2018-11-06 13:27:16 +00:00
|
|
|
controller.unmarkAsReserved(false);
|
2018-07-03 13:23:10 +00:00
|
|
|
|
2018-11-06 13:27:16 +00:00
|
|
|
expect(controller.setReserved).toHaveBeenCalledWith(false);
|
2018-07-03 13:23:10 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('markAsReserved()', () => {
|
|
|
|
it('should call setReserved with true', () => {
|
2018-11-06 13:27:16 +00:00
|
|
|
spyOn(controller, 'setReserved');
|
2018-05-08 07:54:14 +00:00
|
|
|
|
2018-11-06 13:27:16 +00:00
|
|
|
controller.markAsReserved(true);
|
2018-07-03 13:23:10 +00:00
|
|
|
|
2018-11-06 13:27:16 +00:00
|
|
|
expect(controller.setReserved).toHaveBeenCalledWith(true);
|
2018-05-08 07:54:14 +00:00
|
|
|
});
|
2018-07-03 13:23:10 +00:00
|
|
|
});
|
2018-05-08 07:54:14 +00:00
|
|
|
|
2018-09-18 07:52:50 +00:00
|
|
|
describe('setReserved()', () => {
|
2018-07-03 13:23:10 +00:00
|
|
|
it('should call getCheckedLines, $.index.accept and make a query ', () => {
|
2019-09-13 14:09:14 +00:00
|
|
|
const sale = controller.sales[0];
|
2019-07-02 10:12:15 +00:00
|
|
|
sale.checked = true;
|
2018-10-22 06:23:10 +00:00
|
|
|
let expectedRequest = {
|
2019-07-02 10:12:15 +00:00
|
|
|
sales: [sale],
|
2018-10-22 06:23:10 +00:00
|
|
|
ticketFk: ticket.id,
|
|
|
|
reserved: false
|
|
|
|
};
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.expectPOST(`Sales/reserve`, expectedRequest).respond();
|
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
2018-11-06 13:27:16 +00:00
|
|
|
controller.unmarkAsReserved(false);
|
2018-05-08 07:54:14 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
});
|
|
|
|
});
|
2019-03-29 06:29:09 +00:00
|
|
|
|
|
|
|
describe('showSMSDialog()', () => {
|
|
|
|
it('should open an SMS dialog with specified data', () => {
|
|
|
|
spyOn(controller.$scope.sms, 'open');
|
|
|
|
|
2019-09-13 14:09:14 +00:00
|
|
|
controller.sales[0].checked = true;
|
2019-03-29 06:29:09 +00:00
|
|
|
controller.showSMSDialog();
|
|
|
|
|
|
|
|
expect(controller.$scope.sms.open).toHaveBeenCalledWith();
|
2019-04-16 06:21:20 +00:00
|
|
|
expect(controller.newSMS.destination).toEqual(111111111);
|
2019-03-29 06:29:09 +00:00
|
|
|
expect(controller.newSMS.message).not.toEqual('');
|
|
|
|
});
|
|
|
|
});
|
2019-07-02 10:12:15 +00:00
|
|
|
|
|
|
|
describe('updateQuantity()', () => {
|
|
|
|
it('should make a POST query saving sale quantity', () => {
|
2019-09-05 07:00:55 +00:00
|
|
|
spyOn(controller.$scope.watcher, 'updateOriginalData');
|
2019-07-02 10:12:15 +00:00
|
|
|
const data = {quantity: 10};
|
|
|
|
const sale = sales[0];
|
|
|
|
sale.quantity = 10;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('POST', `Sales/4/updateQuantity`, data).respond();
|
|
|
|
$httpBackend.expect('POST', `Sales/4/updateQuantity`, data).respond();
|
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
2019-07-02 10:12:15 +00:00
|
|
|
controller.updateQuantity(sale);
|
|
|
|
$httpBackend.flush();
|
2019-09-05 07:00:55 +00:00
|
|
|
|
|
|
|
expect(controller.$scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
2019-07-02 10:12:15 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('updateConcept()', () => {
|
|
|
|
it('should make a POST query saving sale concept', () => {
|
2019-09-05 07:00:55 +00:00
|
|
|
spyOn(controller.$scope.watcher, 'updateOriginalData');
|
2019-09-06 12:56:56 +00:00
|
|
|
const data = {newConcept: 'My new weapon'};
|
2019-07-02 10:12:15 +00:00
|
|
|
const sale = sales[0];
|
|
|
|
sale.concept = 'My new weapon';
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('POST', `Sales/4/updateConcept`, data).respond();
|
|
|
|
$httpBackend.expect('POST', `Sales/4/updateConcept`, data).respond();
|
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
2019-07-02 10:12:15 +00:00
|
|
|
controller.updateConcept(sale);
|
|
|
|
$httpBackend.flush();
|
2019-09-05 07:00:55 +00:00
|
|
|
|
|
|
|
expect(controller.$scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
2019-07-02 10:12:15 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('addSale()', () => {
|
|
|
|
it('should make a POST query adding a new sale', () => {
|
2019-09-05 07:00:55 +00:00
|
|
|
spyOn(controller.$scope.watcher, 'updateOriginalData');
|
2019-07-02 10:12:15 +00:00
|
|
|
const newSale = {itemFk: 4, quantity: 10};
|
|
|
|
const params = {itemId: 4, quantity: 10};
|
|
|
|
|
|
|
|
const expectedResult = {
|
|
|
|
id: 30,
|
|
|
|
quantity: 10,
|
|
|
|
discount: 0,
|
|
|
|
price: 0,
|
|
|
|
itemFk: 4,
|
|
|
|
item: {
|
|
|
|
subName: 'Item subName',
|
|
|
|
image: '30.png'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('POST', `tickets/1/addSale`, params).respond(expectedResult);
|
|
|
|
$httpBackend.expect('POST', `tickets/1/addSale`, params).respond(expectedResult);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
2019-07-02 10:12:15 +00:00
|
|
|
controller.addSale(newSale);
|
|
|
|
$httpBackend.flush();
|
2019-09-05 07:00:55 +00:00
|
|
|
|
|
|
|
expect(controller.$scope.watcher.updateOriginalData).toHaveBeenCalledWith();
|
2019-07-02 10:12:15 +00:00
|
|
|
});
|
|
|
|
});
|
2019-08-09 06:04:44 +00:00
|
|
|
|
|
|
|
describe('transferSales()', () => {
|
|
|
|
it('should transfer sales to a ticket', () => {
|
|
|
|
spyOn(controller, 'goToTicket');
|
|
|
|
controller.transfer = {
|
|
|
|
sales: [{id: 1, itemFk: 1}, {id: 2, itemFk: 4}]
|
|
|
|
};
|
|
|
|
|
|
|
|
const expectedResponse = {id: 13};
|
|
|
|
const params = {
|
|
|
|
ticketId: 13,
|
|
|
|
sales: controller.transfer.sales
|
|
|
|
};
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('POST', `tickets/1/transferSales`, params).respond(expectedResponse);
|
|
|
|
$httpBackend.expect('POST', `tickets/1/transferSales`, params).respond(expectedResponse);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
2019-08-09 06:04:44 +00:00
|
|
|
controller.transferSales(13);
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.goToTicket).toHaveBeenCalledWith(13);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setTransferParams()', () => {
|
|
|
|
it('should define the transfer object on the controller and its default properties', () => {
|
2019-09-13 14:09:14 +00:00
|
|
|
let sale = controller.sales[0];
|
2019-08-09 06:04:44 +00:00
|
|
|
sale.checked = true;
|
|
|
|
const expectedResponse = [sale];
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('GET', `clients/101/lastActiveTickets?ticketId=1`).respond(expectedResponse);
|
|
|
|
$httpBackend.expect('GET', `clients/101/lastActiveTickets?ticketId=1`).respond(expectedResponse);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
2019-08-09 06:04:44 +00:00
|
|
|
controller.setTransferParams();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
const lastActiveTickets = controller.transfer.lastActiveTickets;
|
|
|
|
|
|
|
|
expect(controller.transfer).toBeDefined();
|
|
|
|
expect(lastActiveTickets).toBeDefined();
|
|
|
|
expect(lastActiveTickets[0].id).toEqual(4);
|
|
|
|
});
|
|
|
|
});
|
2019-09-24 12:03:30 +00:00
|
|
|
|
|
|
|
describe('newOrderFromTicket()', () => {
|
|
|
|
it('should make an HTTP post query and then open the new order on a new tab', () => {
|
|
|
|
const params = {ticketFk: 1};
|
|
|
|
const expectedResponse = {id: 123};
|
|
|
|
|
|
|
|
window.open = jasmine.createSpy('open');
|
|
|
|
controller.$state.href = jasmine.createSpy('href')
|
|
|
|
.and.returnValue('/somePath');
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('POST', `Orders/newFromTicket`, params).respond(expectedResponse);
|
|
|
|
$httpBackend.expect('POST', `Orders/newFromTicket`, params).respond(expectedResponse);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
2019-09-24 12:03:30 +00:00
|
|
|
controller.newOrderFromTicket();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(window.open).toHaveBeenCalledWith('/somePath', '_blank');
|
|
|
|
});
|
|
|
|
});
|
2019-11-14 13:19:39 +00:00
|
|
|
|
|
|
|
describe('hasOneSaleSelected()', () => {
|
|
|
|
it('should return true if just one sale is selected', () => {
|
|
|
|
controller.sales[0].checked = true;
|
|
|
|
|
|
|
|
expect(controller.hasOneSaleSelected()).toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('calculateSalePrice()', () => {
|
|
|
|
it('should make an HTTP post query ', () => {
|
|
|
|
controller.sales[0].checked = true;
|
|
|
|
|
|
|
|
$httpBackend.when('POST', `Sales/4/calculate`).respond(200);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/subtotal`).respond(200, 227.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/getVAT`).respond(200, 10.5);
|
|
|
|
$httpBackend.whenGET(`Tickets/1/isEditable`).respond();
|
|
|
|
|
|
|
|
controller.calculateSalePrice();
|
|
|
|
$httpBackend.flush();
|
|
|
|
});
|
|
|
|
});
|
2018-05-08 07:25:15 +00:00
|
|
|
});
|
|
|
|
});
|