salix/modules/supplier/front/descriptor/index.spec.js

66 lines
2.0 KiB
JavaScript
Raw Permalink Normal View History

2020-10-20 07:44:44 +00:00
import './index.js';
describe('Supplier Component vnSupplierDescriptor', () => {
2020-10-20 07:44:44 +00:00
let $httpBackend;
let controller;
let $httpParamSerializer;
const supplier = {id: 1};
2020-10-20 07:44:44 +00:00
beforeEach(ngModule('supplier'));
2020-10-20 07:44:44 +00:00
beforeEach(inject(($componentController, _$httpBackend_, _$httpParamSerializer_) => {
2020-10-20 07:44:44 +00:00
$httpBackend = _$httpBackend_;
$httpParamSerializer = _$httpParamSerializer_;
controller = $componentController('vnSupplierDescriptor', {$element: null}, {supplier});
2020-10-20 07:44:44 +00:00
}));
describe('loadData()', () => {
it('should perform ask for the supplier', () => {
const filter = {
fields: [
'id',
'name',
'nickname',
'nif',
'payMethodFk',
'payDemFk',
'payDay',
'isActive',
'isReal',
2022-10-26 11:23:54 +00:00
'isTrucker',
'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');
$httpBackend.expect('GET', query).respond({id: 1});
2020-10-20 07:44:44 +00:00
controller.loadData();
$httpBackend.flush();
expect(controller.getData).toHaveBeenCalledTimes(1);
});
});
});