salix/modules/client/front/index/index.spec.js

30 lines
971 B
JavaScript

import './index';
describe('Client index', () => {
let $scope;
let controller;
beforeEach(angular.mock.module('client', $translateProvider => {
$translateProvider.translations('en', {});
}));
beforeEach(angular.mock.inject(($componentController, $rootScope, $state) => {
$scope = $rootScope.$new();
controller = $componentController('vnClientIndex', {$scope, $state});
}));
describe('filterTickets()', () => {
it('should navigate to the ticket index using params as filter', () => {
const client = {id: 101};
const event = {preventDefault: () => {}};
spyOn(event, 'preventDefault');
spyOn(controller.$state, 'go');
controller.filterTickets(client, event);
expect(event.preventDefault).toHaveBeenCalledWith();
expect(controller.$state.go).toHaveBeenCalledWith('ticket.index', jasmine.any(Object));
});
});
});