import './index.js'; describe('Item', () => { describe('Component vnTicketDescriptorPopover', () => { let $componentController; let $scope; let controller; let $httpBackend; let $element; beforeEach(() => { angular.mock.module('item'); }); beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => { $componentController = _$componentController_; $element = angular.element(''); $httpBackend = _$httpBackend_; $httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({}); $scope = $rootScope.$new(); controller = $componentController('vnTicketDescriptorPopover', {$scope, $element, $httpBackend}); controller.parent = 'mariano'; controller.$.popover = {show: () => {}}; })); describe('ticketFk setter', () => { it(`shoud call clear if the given values is null`, () => { spyOn(controller, 'clear'); controller.ticketFk = null; expect(controller.clear).toHaveBeenCalledWith(); expect(controller.ticket).toEqual(null); }); }); describe('quicklinks setter', () => { it(`shoud set _quicklinks to a given value`, () => { controller.quicklinks = 3; expect(controller._quicklinks).toEqual(3); }); }); describe('clear()', () => { it(`should set ticket to null`, () => { controller.ticket = '1'; controller.clear(); expect(controller.ticket).toEqual(null); }); }); describe('show()', () => { it(`should set $.popover.parent and call $.popover.show`, () => { spyOn(controller.$.popover, 'show'); controller.show(); expect(controller.$.popover.show).toHaveBeenCalledWith(); expect(controller.$.popover.parent).toEqual('mariano'); }); }); }); });