2019-07-30 06:51:38 +00:00
|
|
|
import './index';
|
|
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
|
|
|
|
describe('Claim', () => {
|
|
|
|
describe('Component vnClaimDmsIndex', () => {
|
|
|
|
let $componentController;
|
|
|
|
let $scope;
|
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
2019-09-30 12:57:54 +00:00
|
|
|
let $httpParamSerializer;
|
2019-07-30 06:51:38 +00:00
|
|
|
|
2019-09-13 14:09:14 +00:00
|
|
|
beforeEach(angular.mock.module('claim', $translateProvider => {
|
|
|
|
$translateProvider.translations('en', {});
|
|
|
|
}));
|
2019-07-30 06:51:38 +00:00
|
|
|
|
2019-09-30 12:57:54 +00:00
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_, _$httpParamSerializer_) => {
|
2019-07-30 06:51:38 +00:00
|
|
|
$componentController = _$componentController_;
|
2019-09-30 12:57:54 +00:00
|
|
|
$httpParamSerializer = _$httpParamSerializer_;
|
2019-07-30 06:51:38 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
controller = $componentController('vnClaimDmsIndex', {$: $scope});
|
|
|
|
controller.$.model = crudModel;
|
2019-09-30 12:57:54 +00:00
|
|
|
controller.claim = {
|
|
|
|
id: 1,
|
|
|
|
client: {id: 101, name: 'Bruce Wayne'}
|
|
|
|
};
|
2019-07-30 06:51:38 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('deleteDms()', () => {
|
|
|
|
it('should make an HTTP Post query', () => {
|
|
|
|
const dmsId = 1;
|
|
|
|
const dmsIndex = 0;
|
|
|
|
spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
spyOn(controller.$.model, 'remove');
|
2019-09-30 12:57:54 +00:00
|
|
|
controller.photos = [{dmsFk: 1}];
|
2019-07-30 06:51:38 +00:00
|
|
|
controller.dmsIndex = dmsIndex;
|
|
|
|
|
|
|
|
$httpBackend.when('POST', `/api/claimDms/${dmsId}/removeFile`).respond({});
|
|
|
|
$httpBackend.expect('POST', `/api/claimDms/${dmsId}/removeFile`);
|
|
|
|
controller.deleteDms('ACCEPT');
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex);
|
2019-09-30 18:55:41 +00:00
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Photo deleted');
|
2019-09-30 12:57:54 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setDefaultParams()', () => {
|
|
|
|
it('should make an HTTP GET query, then set all dms properties', () => {
|
|
|
|
const params = {filter: {
|
|
|
|
where: {code: 'claim'}
|
|
|
|
}};
|
|
|
|
let serializedParams = $httpParamSerializer(params);
|
|
|
|
$httpBackend.when('GET', `/api/DmsTypes/findOne?${serializedParams}`).respond({});
|
|
|
|
$httpBackend.expect('GET', `/api/DmsTypes/findOne?${serializedParams}`);
|
|
|
|
controller.setDefaultParams();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.dms).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('create()', () => {
|
|
|
|
it('should make an HTTP Post query, then refresh the model data', () => {
|
|
|
|
const claimId = 1;
|
|
|
|
const dmsIndex = 0;
|
|
|
|
spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
spyOn(controller.$.model, 'refresh');
|
|
|
|
controller.photos = [{dmsFk: 1}];
|
|
|
|
controller.dmsIndex = dmsIndex;
|
|
|
|
controller.dms = {files: []};
|
|
|
|
|
|
|
|
$httpBackend.when('POST', `/api/claims/${claimId}/uploadFile`).respond({});
|
|
|
|
$httpBackend.expect('POST', `/api/claims/${claimId}/uploadFile`);
|
|
|
|
controller.create();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.$.model.refresh).toHaveBeenCalledWith();
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Photo uploaded!');
|
2019-07-30 06:51:38 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|