47 lines
1.9 KiB
JavaScript
47 lines
1.9 KiB
JavaScript
import './index';
|
|
import crudModel from 'core/mocks/crud-model';
|
|
|
|
describe('ticket weekly', () => {
|
|
describe('Component vnTicketWeeklyIndex', () => {
|
|
let controller;
|
|
let $httpBackend;
|
|
|
|
beforeEach(ngModule('ticket'));
|
|
|
|
beforeEach(angular.mock.inject(($componentController, _$httpBackend_, $rootScope) => {
|
|
$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()', () => {
|
|
it('should make a query a PATCH querye then call vnApp.showSuccess()', () => {
|
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
|
|
|
$httpBackend.expectPATCH(`TicketWeeklies`).respond();
|
|
controller.onUpdate('ticketFk', 'field', 'value');
|
|
$httpBackend.flush();
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
|
});
|
|
});
|
|
|
|
describe('onDeleteWeeklyAccept()', () => {
|
|
it('should make a DELETE query then call showSuccess(), afterwards checks that remove returns value 0', () => {
|
|
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();
|
|
|
|
expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!');
|
|
expect(controller.$.model.remove).toHaveBeenCalledWith(0);
|
|
});
|
|
});
|
|
});
|
|
});
|