describe('Screen sections tree directive', function() { var scope, compile, $httpBackend; var rawLayout = { id: '1', layout: 'row', name: 'testScreen', panels: [ { id: 'panel1', layout: 'column', name: 'parentPanel', panels: [ { id: 'sec1', name: 'sectionlOne', children: [], span: 4 } ] }, { id: 'panel2', layout: 'column', name: 'parentPanel2', panels: [ { id: 'subPanel', name: 'subPanel', layout: 'row', panels: [ { id: 'sec2', name: 'sectionTwo', children: [], span: 4 } ] }, { id: 'sec3', name: 'sectionThree', children: [], span: 4 } ] } ] }; var rawScreenConfig = { id: '1', title: 'Test Screen', name: 'testScreen', datasource: 'test', panels: [ { id: 'sec1', name: 'sectionlOne', fields: [], type: 'simplePanel' }, { id: 'sec2', name: 'sectionTwo', fields: [ new FieldVO().build({name: 'testField'}) ], type: 'simplePanel' }, ] }; beforeEach(module('myitsmApp', 'templates', 'adminModule')); beforeEach(function(){ inject(function($compile, $rootScope, $injector){ $httpBackend = $injector.get('$httpBackend'); var getLocale = function(){ return readJSON('scripts/app/i18n/resources-locale_en.json'); }; var layoutVO = new LayoutConfigurationVO().build(rawLayout), screenVO = new ScreenConfigurationVO().build(rawScreenConfig); screenVO.layout = layoutVO; $httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(getLocale()); compile = $compile; scope = $rootScope.$new(); scope.screen = screenVO; scope.layout = layoutVO; scope.onItemClick = itemClickHandler; }); }); function itemClickHandler() { } function getCompiledElement(){ var element = angular.element(''); var compiledElement = compile(element)(scope); scope.$digest(); return compiledElement; } it('should compile section tree directive', function(){ var directiveElem = getCompiledElement(); var divElem = directiveElem[0]; expect(divElem).toBeDefined(); }); });