2019-06-06 11:59:11 +00:00
|
|
|
import './index';
|
|
|
|
|
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnClientDmsCreate', () => {
|
|
|
|
let controller;
|
|
|
|
let $scope;
|
|
|
|
let $httpBackend;
|
|
|
|
let $httpParamSerializer;
|
|
|
|
|
|
|
|
beforeEach(ngModule('client'));
|
|
|
|
|
|
|
|
beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$httpParamSerializer = _$httpParamSerializer_;
|
|
|
|
controller = $componentController('vnClientDmsCreate', {$scope});
|
|
|
|
controller._client = {id: 101, name: 'Bruce wayne'};
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('client() setter', () => {
|
|
|
|
it('should set the client data and then call setDefaultParams()', () => {
|
|
|
|
spyOn(controller, 'setDefaultParams');
|
|
|
|
controller.client = {
|
|
|
|
id: 15,
|
|
|
|
name: 'Bruce wayne'
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(controller.client).toBeDefined();
|
|
|
|
expect(controller.setDefaultParams).toHaveBeenCalledWith();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setDefaultParams()', () => {
|
|
|
|
it('should perform a GET query and define the dms property on controller', () => {
|
|
|
|
const params = {filter: {
|
|
|
|
where: {code: 'paymentsLaw'}
|
|
|
|
}};
|
|
|
|
let serializedParams = $httpParamSerializer(params);
|
|
|
|
$httpBackend.when('GET', `/api/DmsTypes/findOne?${serializedParams}`).respond({id: 12, code: 'paymentsLaw'});
|
|
|
|
$httpBackend.expect('GET', `/api/DmsTypes/findOne?${serializedParams}`);
|
|
|
|
controller.setDefaultParams();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.dms).toBeDefined();
|
|
|
|
expect(controller.dms.reference).toEqual(101);
|
|
|
|
expect(controller.dms.dmsTypeId).toEqual(12);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('onFileChange()', () => {
|
2019-07-16 12:12:58 +00:00
|
|
|
it('should set dms hasFileAttached property to true if has any files', () => {
|
2019-06-06 11:59:11 +00:00
|
|
|
const files = [{id: 1, name: 'MyFile'}];
|
|
|
|
controller.onFileChange(files);
|
|
|
|
$scope.$apply();
|
|
|
|
|
2019-07-16 12:12:58 +00:00
|
|
|
expect(controller.dms.hasFileAttached).toBeTruthy();
|
2019-06-06 11:59:11 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|