68 lines
2.1 KiB
JavaScript
68 lines
2.1 KiB
JavaScript
|
import './index.js';
|
||
|
|
||
|
describe('Ticket', () => {
|
||
|
describe('Component vnTicketDataStepTwo', () => {
|
||
|
let controller;
|
||
|
|
||
|
beforeEach(ngModule('ticket'));
|
||
|
|
||
|
beforeEach(angular.mock.inject($componentController => {
|
||
|
controller = $componentController('vnTicketDataStepTwo');
|
||
|
}));
|
||
|
|
||
|
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();
|
||
|
|
||
|
expect(controller.totalPriceDifference).toEqual(3);
|
||
|
});
|
||
|
});
|
||
|
});
|
||
|
});
|