98 lines
3.9 KiB
JavaScript
98 lines
3.9 KiB
JavaScript
/*** Created by npatil2*/
|
|
describe('layoutConfigurationModel', function () {
|
|
beforeEach(module('myitsmApp'));
|
|
var $httpBackend;
|
|
beforeEach(inject(function (layoutConfigurationModel, $injector, $rootScope, $log, $q, layoutConfigurationService, screenConfigurationModel) {
|
|
this.layoutConfigurationModel = layoutConfigurationModel;
|
|
this.scope = $rootScope.$new();
|
|
this.layoutConfigurationService = layoutConfigurationService;
|
|
this.screenConfigurationModel = screenConfigurationModel;
|
|
this.$log = $log;
|
|
this.$q = $q;
|
|
|
|
$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);
|
|
$httpBackend.whenGET('views/dashboard/index.html').respond(200);
|
|
}));
|
|
|
|
beforeEach(inject(function ($q, $rootScope) {
|
|
var deferred = $q.defer(), layouts = [
|
|
{
|
|
id: 'AGGAA5V0HG8SIAOSYVXNABCS8RNIK3',
|
|
name: 'incidentViewScreen',
|
|
layout: 'row',
|
|
panels: [
|
|
{
|
|
id: 'AGGAA5V0HHE9DAOWX5K12YP7B23VOP',
|
|
name: 'summarySection',
|
|
layout: 'fixed',
|
|
panels: [
|
|
{
|
|
id: 'AGGAA5V0HHE9DAOWX5LZ2YQR1Y3VW5',
|
|
name: 'summaryPanel',
|
|
span: 12,
|
|
children: [
|
|
{
|
|
id: 'AGGAA5V0HHE9DAOWX5SM2YVVTQ3W4Z',
|
|
name: 'summary',
|
|
type: 'characterField',
|
|
dataType: 'text'
|
|
}
|
|
]
|
|
}
|
|
],
|
|
notConfigurable: true
|
|
}
|
|
]
|
|
}
|
|
];
|
|
|
|
spyOn(this.layoutConfigurationService, 'loadLayout').and.callFake(function () {
|
|
deferred.resolve(layouts);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.screenConfigurationModel, 'isV2CompatibleScreen').and.callFake(function () {
|
|
deferred.resolve(layouts);
|
|
return deferred.promise;
|
|
});
|
|
|
|
}));
|
|
it('should run getLayoutFromCacheByScreenName ()', function () {
|
|
var screenName = 'changeViewScreen';
|
|
this.myResult = this.layoutConfigurationModel.getLayoutFromCacheByScreenName(screenName);
|
|
console.log(this.myResult);
|
|
})
|
|
|
|
it('should run getLayoutFromCacheByScreenName ()', function () {
|
|
var screenName = 'changeViewScreen';
|
|
this.myResult = this.layoutConfigurationModel.loadLayout(screenName);
|
|
this.scope.$apply();
|
|
console.log(this.myResult);
|
|
expect(this.myResult.$$state.status).toEqual(1);
|
|
})
|
|
|
|
it('should run updateScreenLayout ()', function () {
|
|
var screenName = 'changeViewScreen', layouts = 'row';
|
|
this.myResult = this.layoutConfigurationModel.updateScreenLayout(screenName, layouts);
|
|
console.log(this.myResult);
|
|
expect(this.myResult.$$state.status).toEqual(0);
|
|
});
|
|
|
|
it('should run loadScreenLayout () ', function () {
|
|
var screenName = 'changeViewScreen', flore = 'test foo';
|
|
this.myResult = this.layoutConfigurationModel.loadScreenLayout(screenName, flore);
|
|
this.scope.$apply();
|
|
console.log(this.myResult);
|
|
expect(this.myResult.$$state.status).toEqual(1);
|
|
});
|
|
|
|
});
|
|
|