import './index'; describe('Client', () => { describe('Component vnClientSms', () => { let controller; let $httpBackend; let $element; beforeEach(ngModule('client')); beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { $httpBackend = _$httpBackend_; let $scope = $rootScope.$new(); $element = angular.element(''); controller = $componentController('vnClientSms', {$element, $scope}); controller.client = {id: 101}; controller.$params = {id: 101}; })); describe('onResponse()', () => { it('should perform a POST query and show a success snackbar', () => { let params = {destinationFk: 101, destination: 111111111, message: 'My SMS'}; controller.sms = {destinationFk: 101, destination: 111111111, message: 'My SMS'}; spyOn(controller.vnApp, 'showMessage'); $httpBackend.expect('POST', `Clients/101/sendSms`, params).respond(200, params); controller.onResponse('accept'); $httpBackend.flush(); expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!'); }); }); describe('charactersRemaining()', () => { it('should return the characters remaining in a element', () => { controller.$scope.message = { input: { textLength: 50 }, maxlength: 150 }; let result = controller.charactersRemaining(); expect(result).toEqual(100); }); }); }); });