2020-04-08 10:33:36 +00:00
|
|
|
import './index';
|
|
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
|
|
|
|
describe('ticket weekly', () => {
|
|
|
|
describe('Component vnTicketWeeklyIndex', () => {
|
|
|
|
let controller;
|
|
|
|
let $httpBackend;
|
|
|
|
|
|
|
|
beforeEach(ngModule('ticket'));
|
|
|
|
|
2020-07-23 14:46:16 +00:00
|
|
|
beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => {
|
2020-04-08 10:33:36 +00:00
|
|
|
$httpBackend = _$httpBackend_;
|
|
|
|
const $scope = $rootScope.$new();
|
|
|
|
const $element = angular.element('<vn-ticket-weekly-index></vn-ticket-weekly-index>');
|
|
|
|
controller = $componentController('vnTicketWeeklyIndex', {$element, $scope});
|
|
|
|
}));
|
|
|
|
|
|
|
|
describe('onUpdate()', () => {
|
2020-04-08 11:15:07 +00:00
|
|
|
it('should make a query a PATCH querye then call vnApp.showSuccess()', () => {
|
2020-04-08 10:33:36 +00:00
|
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
|
|
|
|
$httpBackend.expectPATCH(`TicketWeeklies`).respond();
|
|
|
|
controller.onUpdate('ticketFk', 'field', 'value');
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
2020-07-23 15:10:07 +00:00
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
2020-04-08 10:33:36 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('onDeleteWeeklyAccept()', () => {
|
2020-04-08 11:15:07 +00:00
|
|
|
it('should make a DELETE query then call showSuccess(), afterwards checks that remove returns value 0', () => {
|
2020-04-08 10:33:36 +00:00
|
|
|
controller.$.model = crudModel;
|
|
|
|
controller.$.model.data = [{ticketFk: 'ticketFk'}];
|
|
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
jest.spyOn(controller.$.model, 'remove');
|
|
|
|
|
|
|
|
$httpBackend.expectDELETE(`TicketWeeklies/ticketFk`).respond();
|
|
|
|
controller.onDeleteWeeklyAccept('ticketFk');
|
|
|
|
$httpBackend.flush();
|
|
|
|
|
2020-07-23 15:10:07 +00:00
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalled();
|
2020-04-08 10:33:36 +00:00
|
|
|
expect(controller.$.model.remove).toHaveBeenCalledWith(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|