91 lines
2.9 KiB
JavaScript
91 lines
2.9 KiB
JavaScript
import './index.js';
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
describe('ticket', () => {
|
|
describe('Component vnTicketComponents', () => {
|
|
let controller;
|
|
|
|
beforeEach(ngModule('ticket'));
|
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope, $state) => {
|
|
$state.params.id = '1';
|
|
let $scope = $rootScope.$new();
|
|
$scope.model = crudModel;
|
|
$scope.model.data = [{
|
|
components: [
|
|
{
|
|
component: {
|
|
name: 'valor de compra',
|
|
componentType: {
|
|
isBase: 1
|
|
}
|
|
},
|
|
value: 5
|
|
},
|
|
{
|
|
component: {
|
|
name: 'reparto',
|
|
componentType: {
|
|
isBase: 0
|
|
}
|
|
},
|
|
value: 5
|
|
},
|
|
{
|
|
component: {
|
|
name: 'recobro',
|
|
componentType: {
|
|
isBase: 0
|
|
}
|
|
},
|
|
value: 5
|
|
}
|
|
],
|
|
quantity: 1
|
|
},
|
|
{
|
|
components: [
|
|
{
|
|
component: {
|
|
name: 'valor de compra',
|
|
componentType: {
|
|
isBase: 1
|
|
}
|
|
},
|
|
value: 1
|
|
},
|
|
{
|
|
component: {
|
|
name: 'reparto',
|
|
componentType: {
|
|
isBase: 0
|
|
}
|
|
},
|
|
value: 1
|
|
},
|
|
{
|
|
component: {
|
|
name: 'recobro',
|
|
componentType: {
|
|
isBase: 0
|
|
}
|
|
},
|
|
value: 1
|
|
},
|
|
],
|
|
quantity: 5
|
|
}];
|
|
const $element = angular.element('<vn-ticket-components></vn-ticket-components>');
|
|
controller = $componentController('vnTicketComponents', {$element, $scope});
|
|
}));
|
|
|
|
describe('base()', () => {
|
|
it(`should return the sum from all componenets base in each sale`, () => {
|
|
let result = controller.base();
|
|
|
|
expect(result).toEqual(10);
|
|
});
|
|
});
|
|
});
|
|
});
|