42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
import './index';
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
describe('Client', () => {
|
|
describe('Component vnClientDmsIndex', () => {
|
|
let $componentController;
|
|
let $scope;
|
|
let $httpBackend;
|
|
let controller;
|
|
|
|
beforeEach(ngModule('client'));
|
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
|
|
$componentController = _$componentController_;
|
|
$httpBackend = _$httpBackend_;
|
|
$scope = $rootScope.$new();
|
|
const $element = angular.element('<vn-client-dms-index></vn-client-dms-index>');
|
|
controller = $componentController('vnClientDmsIndex', {$element, $scope});
|
|
controller.$.model = crudModel;
|
|
}));
|
|
|
|
describe('deleteDms()', () => {
|
|
it('should make an HTTP Post query', () => {
|
|
const dmsId = 1;
|
|
const dmsIndex = 0;
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
jest.spyOn(controller.$.model, 'remove');
|
|
controller.clientDms = [{dmsFk: 1}];
|
|
controller.dmsIndex = dmsIndex;
|
|
|
|
$httpBackend.when('POST', `clientDms/${dmsId}/removeFile`).respond({});
|
|
$httpBackend.expect('POST', `clientDms/${dmsId}/removeFile`);
|
|
controller.deleteDms('accept');
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex);
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
|
});
|
|
});
|
|
});
|
|
});
|