describe('Test check multiline directive', function () { var compile, scope, $httpBackend; beforeEach(module('myitsmApp')); beforeEach(function () { inject(function ($compile, $rootScope, $injector) { $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; scope = $rootScope.$new(); }); }); function getCompiledElement(multilineContent) { if (!multilineContent) { multilineContent = 'This is one line text.'; } var element = angular.element('

' + multilineContent + '

'), compiledElement = compile(element)(scope); scope.$digest(); return compiledElement; } it('should compile and set isContentMultiline to false if content is of single line', function () { var multilineContent = 'This is one line text.', directiveElem = getCompiledElement(multilineContent), divElem = directiveElem[0], isolateScope = directiveElem.isolateScope(); expect(divElem).toBeDefined(); expect(isolateScope.isContentMultiline).toBeFalsy(); }); it('should successfully watch multilineContent model and set isContentMultiline to false if multilineContent is of one line', function () { var directiveElem = getCompiledElement(), isolateScope = directiveElem.isolateScope(); isolateScope.multilineContent = 'This is content.'; isolateScope.$digest(); expect(isolateScope.isContentMultiline).toBeFalsy(); }); });