2020-10-20 07:44:44 +00:00
|
|
|
import './index.js';
|
|
|
|
|
2020-10-26 07:38:43 +00:00
|
|
|
describe('Supplier Component vnSupplierDescriptor', () => {
|
2020-10-20 07:44:44 +00:00
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
2020-10-26 07:38:43 +00:00
|
|
|
let $httpParamSerializer;
|
|
|
|
const supplier = {id: 1};
|
2020-10-20 07:44:44 +00:00
|
|
|
|
2020-10-26 07:38:43 +00:00
|
|
|
beforeEach(ngModule('supplier'));
|
2020-10-20 07:44:44 +00:00
|
|
|
|
2020-10-26 07:38:43 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => {
|
2020-10-20 07:44:44 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
2020-10-26 07:38:43 +00:00
|
|
|
$httpParamSerializer = _$httpParamSerializer_;
|
|
|
|
controller = $componentController('vnSupplierDescriptor', {$element: null}, {supplier});
|
2020-10-20 07:44:44 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('loadData()', () => {
|
2020-10-26 07:38:43 +00:00
|
|
|
it('should perform ask for the supplier', () => {
|
|
|
|
const filter = {
|
|
|
|
fields: [
|
|
|
|
'id',
|
|
|
|
'name',
|
|
|
|
'nickname',
|
|
|
|
'nif',
|
|
|
|
'payMethodFk',
|
|
|
|
'payDemFk',
|
|
|
|
'payDay',
|
|
|
|
'isActive',
|
2024-04-09 15:31:34 +00:00
|
|
|
'isReal',
|
2022-10-26 11:23:54 +00:00
|
|
|
'isTrucker',
|
2020-10-26 07:38:43 +00:00
|
|
|
'account'
|
|
|
|
],
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
relation: 'payMethod',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'name']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'payDem',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'payDem']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
relation: 'client',
|
|
|
|
scope: {
|
|
|
|
fields: ['id', 'fi']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
const serializedParams = $httpParamSerializer({filter});
|
|
|
|
let query = `Suppliers/${controller.supplier.id}?${serializedParams}`;
|
2020-10-20 07:44:44 +00:00
|
|
|
jest.spyOn(controller, 'getData');
|
|
|
|
|
2020-10-26 07:38:43 +00:00
|
|
|
$httpBackend.expect('GET', query).respond({id: 1});
|
2020-10-20 07:44:44 +00:00
|
|
|
controller.loadData();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.getData).toHaveBeenCalledTimes(1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|