salix/modules/ticket/front/component/index.spec.js

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: [
{
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
}];
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);
});
});
});
});