import './index'; describe('Client', () => { describe('Component vnClientAddressIndex', () => { let controller; let $scope; let $state; let $httpBackend; beforeEach(ngModule('client')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$state_, _$httpBackend_) => { $state = _$state_; $httpBackend = _$httpBackend_; $scope = $rootScope.$new(); $scope.model = { refresh: () => {} }; controller = $componentController('vnClientAddressIndex', {$state, $scope}); })); describe('setDefault()', () => { it('should perform a PATCH if the address is active and call the refresh method', () => { spyOn($scope.model, 'refresh'); let address = {id: 1, isActive: true}; $httpBackend.when('PATCH', `/client/api/Addresses/1`).respond(200); $httpBackend.expect('PATCH', `/client/api/Addresses/1`); controller.setDefault(address); $httpBackend.flush(); expect($scope.model.refresh).toHaveBeenCalledWith(); }); }); }); });