2019-01-25 11:52:12 +00:00
|
|
|
import './index.js';
|
|
|
|
|
|
|
|
describe('Ticket', () => {
|
2019-04-16 13:00:21 +00:00
|
|
|
describe('Component vnTicketBasicDataStepTwo', () => {
|
2019-01-25 11:52:12 +00:00
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('ticket'));
|
2019-01-25 11:52:12 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject($componentController => {
|
2020-03-18 07:35:59 +00:00
|
|
|
const $element = angular.element('<vn-ticket-basic-data-step-two><vn-ticket-basic-data-step-two>');
|
|
|
|
controller = $componentController('vnTicketBasicDataStepTwo', {$element});
|
2019-01-25 11:52:12 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('getTotalPrice()', () => {
|
|
|
|
it('should calculate the total price of the sale based on the data received', () => {
|
|
|
|
controller.ticket = {
|
|
|
|
sale: {
|
|
|
|
items: [{
|
|
|
|
quantity: 10,
|
|
|
|
price: 0.1,
|
|
|
|
component: {newPrice: 0.2, difference: 0.3}
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.getTotalPrice();
|
|
|
|
|
|
|
|
expect(controller.totalPrice).toEqual(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('getTotalNewPrice()', () => {
|
|
|
|
it('should calculate the total new price of the sale based on the data received', () => {
|
|
|
|
controller.ticket = {
|
|
|
|
sale: {
|
|
|
|
items: [{
|
|
|
|
quantity: 10,
|
|
|
|
price: 0.1,
|
|
|
|
component: {newPrice: 0.2, difference: 0.3}
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.getTotalNewPrice();
|
|
|
|
|
|
|
|
expect(controller.totalNewPrice).toEqual(2);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('getTotalDifferenceOfPrice()', () => {
|
|
|
|
it('should calculate the total price difference of the sale based on the data received', () => {
|
|
|
|
controller.ticket = {
|
|
|
|
sale: {
|
|
|
|
items: [{
|
|
|
|
quantity: 10,
|
|
|
|
price: 0.1,
|
|
|
|
component: {newPrice: 0.2, difference: 0.3}
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.getTotalDifferenceOfPrice();
|
|
|
|
|
2019-05-09 07:32:04 +00:00
|
|
|
expect(controller.totalPriceDifference).toEqual(0.3);
|
2019-01-25 11:52:12 +00:00
|
|
|
});
|
|
|
|
});
|
2021-12-16 07:14:27 +00:00
|
|
|
|
2021-12-21 19:58:58 +00:00
|
|
|
describe('ticketHaveNegatives()', () => {
|
|
|
|
it('should show if ticket have any negative and any not negative', () => {
|
2021-12-16 07:14:27 +00:00
|
|
|
controller.ticket = {
|
|
|
|
sale: {
|
2021-12-21 19:58:58 +00:00
|
|
|
items: [
|
|
|
|
{
|
|
|
|
item: 1,
|
|
|
|
quantity: 2,
|
2022-01-26 07:54:48 +00:00
|
|
|
movable: 1
|
2021-12-21 19:58:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
item: 2,
|
|
|
|
quantity: 1,
|
2022-01-26 07:54:48 +00:00
|
|
|
movable: 5
|
2021-12-21 19:58:58 +00:00
|
|
|
}
|
|
|
|
]
|
2021-12-16 07:14:27 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.ticketHaveNegatives();
|
|
|
|
|
|
|
|
expect(controller.haveNegatives).toEqual(true);
|
|
|
|
});
|
|
|
|
});
|
2019-01-25 11:52:12 +00:00
|
|
|
});
|
|
|
|
});
|