import './index'; describe('Ticket Component vnTicketSearchPanel', () => { let $httpBackend; let controller; beforeEach(ngModule('ticket')); beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; controller = $componentController('vnTicketSearchPanel', {$element: null}); controller.$t = () => {}; })); describe('getGroupedStates()', () => { it('should set an array of groupedStates with the aditionof a name translation', () => { jest.spyOn(controller, '$t').mockReturnValue('miCodigo'); const data = [ { alertLevel: 9999, code: 'myCode' } ]; $httpBackend.whenGET('AlertLevels').respond(data); controller.getGroupedStates(); $httpBackend.flush(); expect(controller.groupedStates).toEqual([{ alertLevel: 9999, code: 'myCode', name: 'miCodigo' }]); }); }); });