115 lines
2.3 KiB
JavaScript
115 lines
2.3 KiB
JavaScript
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('<screen-sections-tree layout="layout" screen="screen" on-item-click="onItemClick(panel, allPanels, otherSelectedFields)"></screen-sections-tree>');
|
|
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();
|
|
});
|
|
}); |