Code coverage report for js/directives/simple-chat/simple-chat.js

Statements: 80% (16 / 20)      Branches: 80% (8 / 10)      Functions: 60% (3 / 5)      Lines: 80% (16 / 20)      Ignored: none     

All files » js/directives/simple-chat/ » simple-chat.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 621         1 1                                   1   1 1         1       1       1           1         1 2   2 1   2 1      
angular
    .module('angular-simple-chat.directives')
    .directive('simpleChat', simpleChat);
 
/* @ngInject */
function simpleChat($timeout) {
    var directive = {
        bindToController: true,
        controller: 'simpleChatController',
        controllerAs: 'sc',
        link: link,
        restrict: 'AE',
        templateUrl: 'directives/simple-chat/simple-chat.html',
        scope: {
            messages: '=',
            localUser: '=',
            toUser: '=',
            sendFunction: '=',
            showUserAvatar: '=',
            showComposer: '=',
            sendButtonText: '@',
            composerPlaceholderText: '@'
        }
    };
    return directive;
 
    function link(scope, element, attrs, ctrl) {
        var $simpleChatContainer = angular.element(element.children()[0])[0],
            scrollToBottom = function() {
                $simpleChatContainer.scrollTop = $simpleChatContainer.scrollHeight;
            };
 
        scope.$on('simple-chat-message-posted', function() {
            $timeout(scrollToBottom, 0);
        });
 
        Iif (angular.isDefined(ctrl.messages) && ctrl.messages.length > 0) {
            $timeout(scrollToBottom, 0);
        }
 
        Iif (angular.isUndefined(ctrl.messages)) {
            ctrl.messages = [];
        }
    }
}
 
angular
    .module('angular-simple-chat.directives')
    .controller('simpleChatController', simpleChatController);
 
/* @ngInject */
function simpleChatController() {
    this.options = new SimpleChatConfig();
 
    if (angular.isDefined(this.showUserAvatar)) {
        this.options.setShowUserAvatar(this.showUserAvatar);
    }
    if (angular.isDefined(this.showComposer)) {
        this.options.setShowComposer(this.showComposer);
    }
}