SmartIT_Extensions/BMC/smart-it-full/test/app/common/person-avatar-menu.spec.js

50 lines
1.8 KiB
JavaScript

describe('Test person avatar menu', function () {
'use strict';
var compile, scope, $httpBackend, timeout;
beforeEach(module('myitsmApp', 'templates'));
beforeEach(function () {
inject(function ($compile, $rootScope, $injector, $timeout) {
$httpBackend = $injector.get('$httpBackend');
var getLocale = function () {
return readJSON('scripts/app/i18n/resources-locale_en.json');
};
$httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(getLocale());
$httpBackend.whenGET('/smartit/rest/serverstates').respond(200);
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200);
compile = $compile;
scope = $rootScope.$new();
timeout = $timeout;
});
});
function getCompiledElement(address) {
var compiledElement = compile(angular.element('<div person-menu="person"><div class="chat-availability__holder"></div></div>'))(scope);
scope.$digest();
return compiledElement;
}
it('should compile', function () {
var directiveElem = getCompiledElement(),
divElem = directiveElem[0];
expect(divElem).toBeDefined();
});
it('should open menu option on click of avatar', function () {
var directiveElem = getCompiledElement(),
ele = directiveElem.find('.chat-availability__holder');
ele.data('$isolateScope', { userInfo: { jid: '123' }} );
ele.trigger('click');
timeout.flush();
expect(scope.avatarMenu.menuContext.jid).toBe('123');
expect(scope.avatarMenu.actionsList[1].disabledAction).toBeTruthy();
expect(scope.avatarMenu.actionsList[1].hiddenAction).toBeTruthy();
expect(scope.avatarMenu.isActive).toBeTruthy();
});
});