2019-07-30 06:51:38 +00:00
|
|
|
import './index';
|
|
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
|
|
|
|
describe('Claim', () => {
|
2020-01-10 10:29:11 +00:00
|
|
|
describe('Component vnClaimPhotos', () => {
|
2019-07-30 06:51:38 +00:00
|
|
|
let $scope;
|
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('claim'));
|
2019-07-30 06:51:38 +00:00
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
2019-07-30 06:51:38 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
2020-04-28 12:26:02 +00:00
|
|
|
controller = $componentController('vnClaimPhotos', {$element: null, $scope});
|
2019-07-30 06:51:38 +00:00
|
|
|
controller.$.model = crudModel;
|
2019-09-30 12:57:54 +00:00
|
|
|
controller.claim = {
|
|
|
|
id: 1,
|
2021-06-23 11:24:23 +00:00
|
|
|
client: {id: 1101, name: 'Bruce Wayne'}
|
2019-09-30 12:57:54 +00:00
|
|
|
};
|
2019-07-30 06:51:38 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
describe('deleteDms()', () => {
|
|
|
|
it('should make an HTTP Post query', () => {
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
jest.spyOn(controller.$.model, 'remove');
|
2020-04-28 12:26:02 +00:00
|
|
|
|
|
|
|
const dmsId = 1;
|
|
|
|
const dmsIndex = 0;
|
2019-09-30 12:57:54 +00:00
|
|
|
controller.photos = [{dmsFk: 1}];
|
2019-07-30 06:51:38 +00:00
|
|
|
|
2020-04-28 12:26:02 +00:00
|
|
|
$httpBackend.expectPOST(`ClaimDms/${dmsId}/removeFile`).respond();
|
|
|
|
controller.deleteDms(dmsIndex);
|
2019-07-30 06:51:38 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex);
|
2020-04-28 12:26:02 +00:00
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
2019-09-30 12:57:54 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('setDefaultParams()', () => {
|
|
|
|
it('should make an HTTP GET query, then set all dms properties', () => {
|
2020-04-28 12:26:02 +00:00
|
|
|
$httpBackend.expectRoute('GET', `DmsTypes/findOne`).respond({});
|
2019-09-30 12:57:54 +00:00
|
|
|
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;
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
jest.spyOn(controller.$.model, 'refresh');
|
2019-09-30 12:57:54 +00:00
|
|
|
controller.photos = [{dmsFk: 1}];
|
|
|
|
controller.dmsIndex = dmsIndex;
|
|
|
|
controller.dms = {files: []};
|
|
|
|
|
2020-04-28 12:26:02 +00:00
|
|
|
$httpBackend.expectPOST(`claims/${claimId}/uploadFile`).respond({});
|
2019-09-30 12:57:54 +00:00
|
|
|
controller.create();
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
2020-04-28 12:26:02 +00:00
|
|
|
expect(controller.$.model.refresh).toHaveBeenCalled();
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
2019-07-30 06:51:38 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|