2019-07-30 06:51:38 +00:00
|
|
|
import './index';
|
|
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
|
|
|
|
describe('Client', () => {
|
|
|
|
describe('Component vnClientDmsIndex', () => {
|
|
|
|
let $componentController;
|
|
|
|
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
|
|
|
|
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
|
|
|
|
$componentController = _$componentController_;
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
|
|
|
controller = $componentController('vnClientDmsIndex', {$: $scope});
|
|
|
|
controller.$.model = crudModel;
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('deleteDms()', () => {
|
|
|
|
it('should make an HTTP Post query', () => {
|
|
|
|
const dmsId = 1;
|
|
|
|
const dmsIndex = 0;
|
|
|
|
spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
spyOn(controller.$.model, 'remove');
|
|
|
|
controller.clientDms = [{dmsFk: 1}];
|
|
|
|
controller.dmsIndex = dmsIndex;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('POST', `clientDms/${dmsId}/removeFile`).respond({});
|
|
|
|
$httpBackend.expect('POST', `clientDms/${dmsId}/removeFile`);
|
2019-07-30 06:51:38 +00:00
|
|
|
controller.deleteDms('ACCEPT');
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex);
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|