salix/modules/worker/front/dms/index/index.spec.js

38 lines
1.3 KiB
JavaScript
Raw Normal View History

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
beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => {
2019-11-22 09:42:05 +00:00
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
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');
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
$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);
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
2019-11-22 09:42:05 +00:00
});
});
});
});