SmartIT_Extensions/BMC/smart-it-full/test/app/resource/rs-resource-preview-directi...

52 lines
1.9 KiB
JavaScript

describe('Test rs resource preview directive', function () {
var compile, scope, $httpBackend, rootScope, events;
beforeEach(module('myitsmApp', 'templates'));
beforeEach(function () {
inject(function ($compile, $rootScope, $injector, _events_) {
$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/v2/metadata?type=global').respond(200);
compile = $compile;
rootScope = $rootScope;
scope = $rootScope.$new();
events = _events_;
});
});
beforeEach(function () {
scope.context = {
id: 'AGGAA5V0HGVEGAP13TZDP07AZCZX4H',
type: 'knowledge',
status: {
value: 'Work In Progress'
}
}
});
function getCompiledElement() {
var element = angular.element('<rs-resource-preview context="context"></rs-resource-preview>');
var compiledElement = compile(element)(scope);
scope.$digest();
return compiledElement;
}
it('should compile', function () {
var directiveElem = getCompiledElement(),
divElem = directiveElem[0];
expect(divElem).toBeDefined();
});
it('should successfully handle MULTILINE_CONTENT_CHANGED event and set the true value of isTitleMultiline', function () {
var directiveElem = getCompiledElement(),
isolateScope = directiveElem.isolateScope();
expect(isolateScope.isTitleMultiline).toBeFalsy();
rootScope.$broadcast(events.MULTILINE_CONTENT_CHANGED, {isContentMultiline: true});
isolateScope.$digest();
expect(isolateScope.isTitleMultiline).toBeTruthy();
});
});