2019-11-22 09:42:05 +00:00
|
|
|
import './index';
|
|
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
|
2019-11-25 08:17:24 +00:00
|
|
|
describe('Worker', () => {
|
|
|
|
describe('Component vnWorkerDmsIndex', () => {
|
2019-11-22 09:42:05 +00:00
|
|
|
let $componentController;
|
|
|
|
let $scope;
|
2019-11-25 08:17:24 +00:00
|
|
|
let $element;
|
2019-11-22 09:42:05 +00:00
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
|
|
|
|
2019-11-25 08:17:24 +00:00
|
|
|
beforeEach(ngModule('worker'));
|
2019-11-22 09:42:05 +00:00
|
|
|
|
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
|
|
|
|
$componentController = _$componentController_;
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
2019-11-25 08:17:24 +00:00
|
|
|
$element = angular.element(`<vn-worker-dms-index></vn-worker-dms-index`);
|
|
|
|
controller = $componentController('vnWorkerDmsIndex', {$element, $scope});
|
2019-11-22 09:42:05 +00:00
|
|
|
controller.$.model = crudModel;
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('deleteDms()', () => {
|
|
|
|
it('should make an HTTP Post query', () => {
|
2019-11-25 08:17:24 +00:00
|
|
|
const dmsId = 4;
|
2019-11-22 09:42:05 +00:00
|
|
|
const dmsIndex = 0;
|
|
|
|
spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
spyOn(controller.$.model, 'remove');
|
2019-11-25 08:17:24 +00:00
|
|
|
controller.workerDms = [{dmsFk: 4}];
|
2019-11-22 09:42:05 +00:00
|
|
|
controller.dmsIndex = dmsIndex;
|
|
|
|
|
2019-11-25 08:17:24 +00:00
|
|
|
$httpBackend.when('POST', `WorkerDms/${dmsId}/removeFile`).respond({});
|
|
|
|
$httpBackend.expect('POST', `WorkerDms/${dmsId}/removeFile`);
|
2019-11-22 09:42:05 +00:00
|
|
|
controller.deleteDms('accept');
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex);
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|