Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
gerard 2018-08-22 14:24:47 +02:00
commit 8ff2e40998
5 changed files with 164 additions and 1 deletions

View File

@ -21,6 +21,7 @@ Sent: Enviado
Worker: Trabajador Worker: Trabajador
Send: Enviar Send: Enviar
Sample: Plantilla Sample: Plantilla
Credit: Crédito
# Sections # Sections
Clients: Clientes Clients: Clientes

View File

@ -6,3 +6,4 @@ Risk: Riesgo
Secured credit: Crédito asegurado Secured credit: Crédito asegurado
Average invoiced: Consumo medio Average invoiced: Consumo medio
Sales person: Comercial Sales person: Comercial
Recovery: Recobro

View File

@ -0,0 +1,63 @@
import './index.js';
describe('Item', () => {
describe('Component vnItemIndex', () => {
let $componentController;
let $state;
let controller;
let $httpBackend;
beforeEach(() => {
angular.mock.module('item');
});
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
$componentController = _$componentController_;
$state = _$state_;
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
controller = $componentController('vnItemIndex', {$state: $state});
}));
describe('onCloneAccept()', () => {
it('should do nothing if response is not ACCEPT', () => {
spyOn(controller.$state, 'go');
let response = 'ERROR!';
controller.itemSelected = 'check me';
controller.onCloneAccept(response);
expect(controller.$state.go).not.toHaveBeenCalledWith();
expect(controller.itemSelected).toEqual('check me');
});
it('should do nothing if response is ACCEPT but itemSelected is not defined in the controller', () => {
spyOn(controller.$state, 'go');
let response = 'ACCEPT';
controller.itemSelected = undefined;
controller.onCloneAccept(response);
expect(controller.$state.go).not.toHaveBeenCalledWith();
expect(controller.itemSelected).toBeUndefined();
});
it('should perform a post query and then call go() then update itemSelected in the controller', () => {
spyOn(controller.$state, 'go');
let response = 'ACCEPT';
controller.itemSelected = {id: 1};
$httpBackend.when('POST', `/item/api/Items/1/clone`).respond({id: 99});
$httpBackend.expect('POST', `/item/api/Items/1/clone`);
controller.onCloneAccept(response);
$httpBackend.flush();
expect(controller.$state.go).toHaveBeenCalledWith('item.card.tags', {id: 99});
expect(controller.itemSelected).toBeNull();
});
});
});
});

View File

@ -0,0 +1,52 @@
import './index.js';
describe('Item', () => {
describe('Component vnItemSearchPanel', () => {
let $componentController;
let $element;
let controller;
let $httpBackend;
beforeEach(() => {
angular.mock.module('item');
});
beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => {
$componentController = _$componentController_;
$element = angular.element(`<div></div>`);
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
controller = $componentController('vnItemSearchPanel', {$element: $element});
}));
describe('getSourceTable()', () => {
it(`should return null if there's no selection`, () => {
let selection = null;
let result = controller.getSourceTable(selection);
expect(result).toBeNull();
});
it(`should return null if there's a selection but its isFree property is truthy`, () => {
let selection = {isFree: true};
let result = controller.getSourceTable(selection);
expect(result).toBeNull();
});
it(`should return the formated sourceTable concatenated to a path`, () => {
let selection = {sourceTable: 'hello guy'};
let result = controller.getSourceTable(selection);
expect(result).toEqual('/api/Hello guys');
});
it(`should return a path if there's no sourceTable and the selection has an id`, () => {
let selection = {id: 99};
let result = controller.getSourceTable(selection);
expect(result).toEqual(`/api/ItemTags/filterItemTags/${selection.id}`);
});
});
});
});

View File

@ -0,0 +1,46 @@
const app = require(`${servicesDir}/client/server/server`);
describe('client summary()', () => {
it('should return a summary object containing data', async() => {
let result = await app.models.Client.summary(101);
expect(result.id).toEqual(101);
expect(result.name).toEqual('Bruce Wayne');
});
it('should return a summary object containing mana', async() => {
let result = await app.models.Client.summary(101);
expect(result.mana.mana).toEqual(260);
});
it('should return a summary object containing debt', async() => {
let result = await app.models.Client.summary(101);
expect(result.debt.debt).toEqual(1389.9);
});
it('should return a summary object containing averageInvoiced', async() => {
let result = await app.models.Client.summary(101);
expect(result.averageInvoiced.invoiced).toEqual(1500);
});
it('should return a summary object containing totalGreuge', async() => {
let result = await app.models.Client.summary(101);
expect(result.totalGreuge).toEqual(203.71);
});
it('should return a summary object without containing active recoveries', async() => {
let result = await app.models.Client.summary(101);
expect(result.recovery).toEqual(null);
});
it('should return a summary object containing active recoveries', async() => {
let result = await app.models.Client.summary(102);
expect(result.recovery.id).toEqual(3);
});
});