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-10-24 22:53:53 +00:00
|
|
|
beforeEach(ngModule('ticket'));
|
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;
|
2020-02-26 12:22:52 +00:00
|
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
jest.spyOn(controller.$.model, 'remove');
|
2019-07-30 06:51:38 +00:00
|
|
|
controller.ticketDms = [{dmsFk: 1}];
|
|
|
|
controller.dmsIndex = dmsIndex;
|
|
|
|
|
2019-10-24 22:53:53 +00:00
|
|
|
$httpBackend.when('POST', `ticketDms/${dmsId}/removeFile`).respond({});
|
|
|
|
$httpBackend.expect('POST', `ticketDms/${dmsId}/removeFile`);
|
2019-10-30 15:57:14 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|