2019-05-01 16:49:39 +00:00
|
|
|
import './index';
|
2019-07-30 06:51:38 +00:00
|
|
|
import crudModel from 'core/mocks/crud-model';
|
2019-05-01 16:49:39 +00:00
|
|
|
|
2019-07-30 06:51:38 +00:00
|
|
|
describe('Ticket', () => {
|
|
|
|
describe('Component vnTicketDmsIndex', () => {
|
2019-05-01 16:49:39 +00:00
|
|
|
let $componentController;
|
|
|
|
let $scope;
|
|
|
|
let $httpBackend;
|
|
|
|
let controller;
|
|
|
|
|
2019-09-13 14:09:14 +00:00
|
|
|
beforeEach(angular.mock.module('ticket', $translateProvider => {
|
|
|
|
$translateProvider.translations('en', {});
|
|
|
|
}));
|
2019-05-01 16:49:39 +00:00
|
|
|
|
2019-07-30 06:51:38 +00:00
|
|
|
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
|
2019-05-01 16:49:39 +00:00
|
|
|
$componentController = _$componentController_;
|
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
$scope = $rootScope.$new();
|
2019-07-30 06:51:38 +00:00
|
|
|
controller = $componentController('vnTicketDmsIndex', {$: $scope});
|
|
|
|
controller.$.model = crudModel;
|
2019-05-01 16:49:39 +00:00
|
|
|
}));
|
|
|
|
|
2019-07-30 06:51:38 +00:00
|
|
|
describe('deleteDms()', () => {
|
|
|
|
it('should make an HTTP Post query', () => {
|
|
|
|
const dmsId = 1;
|
|
|
|
const dmsIndex = 0;
|
|
|
|
spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
spyOn(controller.$.model, 'remove');
|
|
|
|
controller.ticketDms = [{dmsFk: 1}];
|
|
|
|
controller.dmsIndex = dmsIndex;
|
|
|
|
|
|
|
|
$httpBackend.when('POST', `/api/ticketDms/${dmsId}/removeFile`).respond({});
|
|
|
|
$httpBackend.expect('POST', `/api/ticketDms/${dmsId}/removeFile`);
|
|
|
|
controller.deleteDms('ACCEPT');
|
2019-05-01 16:49:39 +00:00
|
|
|
$httpBackend.flush();
|
|
|
|
|
2019-07-30 06:51:38 +00:00
|
|
|
expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex);
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
2019-05-01 16:49:39 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|