38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
import './index';
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
describe('Ticket', () => {
|
|
describe('Component vnTicketDmsIndex', () => {
|
|
let $httpBackend;
|
|
let controller;
|
|
|
|
beforeEach(ngModule('ticket'));
|
|
|
|
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
|
|
$httpBackend = _$httpBackend_;
|
|
const $element = angular.element('<vn-ticket-dms-index></vn-ticket-dms-index>');
|
|
controller = $componentController('vnTicketDmsIndex', {$element});
|
|
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.ticketDms = [{dmsFk: 1}];
|
|
controller.dmsIndex = dmsIndex;
|
|
|
|
$httpBackend.when('POST', `ticketDms/${dmsId}/removeFile`).respond({});
|
|
$httpBackend.expect('POST', `ticketDms/${dmsId}/removeFile`);
|
|
controller.deleteDms('accept');
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex);
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
|
});
|
|
});
|
|
});
|
|
});
|