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 $scope;
|
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
|
|
|
|
2019-11-25 08:17:24 +00:00
|
|
|
beforeEach(ngModule('worker'));
|
2019-11-22 09:42:05 +00:00
|
|
|
|
2020-04-28 12:26:02 +00:00
|
|
|
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
|
2019-11-22 09:42:05 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
2020-04-28 12:26:02 +00:00
|
|
|
controller = $componentController('vnWorkerDmsIndex', {$element: null, $scope});
|
2019-11-22 09:42:05 +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 workerDmsId = 4;
|
|
|
|
const dmsIndex = 0;
|
2020-03-02 06:57:33 +00:00
|
|
|
controller.workerDms = [{id: 1, dmsFk: 4}];
|
2019-11-22 09:42:05 +00:00
|
|
|
|
2020-04-28 12:26:02 +00:00
|
|
|
$httpBackend.expectPOST(`WorkerDms/${workerDmsId}/removeFile`).respond();
|
|
|
|
controller.deleteDms(dmsIndex);
|
2019-11-22 09:42:05 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
|
|
|
expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex);
|
2020-04-28 12:26:02 +00:00
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
2019-11-22 09:42:05 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|