90 lines
2.8 KiB
JavaScript
90 lines
2.8 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: [
|
|
{
|
|
componentRate: {
|
|
name: 'valor de compra',
|
|
componentType: {
|
|
isBase: 1
|
|
}
|
|
},
|
|
value: 5
|
|
},
|
|
{
|
|
componentRate: {
|
|
name: 'reparto',
|
|
componentType: {
|
|
isBase: 0
|
|
}
|
|
},
|
|
value: 5
|
|
},
|
|
{
|
|
componentRate: {
|
|
name: 'recobro',
|
|
componentType: {
|
|
isBase: 0
|
|
}
|
|
},
|
|
value: 5
|
|
}
|
|
],
|
|
quantity: 1
|
|
},
|
|
{
|
|
components: [
|
|
{
|
|
componentRate: {
|
|
name: 'valor de compra',
|
|
componentType: {
|
|
isBase: 1
|
|
}
|
|
},
|
|
value: 1
|
|
},
|
|
{
|
|
componentRate: {
|
|
name: 'reparto',
|
|
componentType: {
|
|
isBase: 0
|
|
}
|
|
},
|
|
value: 1
|
|
},
|
|
{
|
|
componentRate: {
|
|
name: 'recobro',
|
|
componentType: {
|
|
isBase: 0
|
|
}
|
|
},
|
|
value: 1
|
|
},
|
|
],
|
|
quantity: 5
|
|
}];
|
|
controller = $componentController('vnTicketComponents', {$scope});
|
|
}));
|
|
|
|
describe('base()', () => {
|
|
it(`should return the sum from all componenets base in each sale`, () => {
|
|
let result = controller.base();
|
|
|
|
expect(result).toEqual(10);
|
|
});
|
|
});
|
|
});
|
|
});
|