2019-07-30 06:51:38 +00:00
|
|
|
import './index';
|
|
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
|
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnClientDmsIndex', () => {
|
|
|
|
let $scope;
|
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('client'));
|
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('vnClientDmsIndex', {$element: null, $scope});
|
2019-07-30 06:51:38 +00:00
|
|
|
controller.$.model = crudModel;
|
|
|
|
}));
|
|
|
|
|
|
|
|
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-07-30 06:51:38 +00:00
|
|
|
controller.clientDms = [{dmsFk: 1}];
|
|
|
|
|
2020-04-28 12:26:02 +00:00
|
|
|
$httpBackend.expectPOST(`ClientDms/${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-07-30 06:51:38 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|