188 lines
6.5 KiB
JavaScript
188 lines
6.5 KiB
JavaScript
/**
|
|
* Created by abhatkha on 5/23/17.
|
|
*/
|
|
//This is test suite for KnowledgeStyleConfigController
|
|
|
|
describe("Test Controller KnowledgeStyleConfigController", function() {
|
|
|
|
var scope, knowledgeArticleModel, systemAlertService, $filter,customLocale, createController, controller;
|
|
beforeEach(module('myitsmApp'));
|
|
beforeEach(module('adminModule'));
|
|
beforeEach(module('knowledgeArticleModule'));
|
|
beforeEach(inject(function ($rootScope, $controller, $injector, _knowledgeArticleModel_, _systemAlertService_, _$filter_, _customLocale_ ) {
|
|
//$location = _$location_;
|
|
scope = $rootScope.$new();
|
|
//$injector.get('customLocale');
|
|
|
|
knowledgeArticleModel = _knowledgeArticleModel_;
|
|
systemAlertService = _systemAlertService_;
|
|
$filter = _$filter_;
|
|
customLocale = $injector.get('customLocale');
|
|
createController = function() {
|
|
return $controller('KnowledgeStyleConfigController', {
|
|
'$scope': scope
|
|
});
|
|
};
|
|
controller = createController();
|
|
}));
|
|
|
|
it(' should run selectTemplate method and set templateObject ',function(){
|
|
|
|
var taskTemplate = new TaskTemplateVO();
|
|
expect(scope.selectedTemplate).toEqual({});
|
|
taskTemplate.templateObject = {'name':'testTemplate','styles':[scope.selectedStyle] };
|
|
|
|
scope.selectTemplate(taskTemplate);
|
|
expect(scope.selectedTemplate).not.toEqual({});
|
|
});
|
|
|
|
it(' should run deleteStyle method ', function() {
|
|
|
|
var taskTemplate = new TaskTemplateVO();
|
|
taskTemplate.templateObject = {'name':'testTemplate2','styles':[scope.selectedStyle] };
|
|
scope.selectTemplate(taskTemplate);
|
|
scope.addStyle();
|
|
|
|
$e = document.createEvent('Event');
|
|
scope.deleteStyle(0,$e);
|
|
expect(scope.isDirtyState).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
it(' should run selectStyle method and set scope.selectedStyle ', function() {
|
|
//controller = createController();
|
|
var selectedStyle = {styles: "text-decoration: underline; font-weight: bold; font-style: italic;",isExpanded:false};
|
|
scope.selectedStyle = {styles: "text-decoration': underline; font-weight: bold; font-style: italic;",isExpanded:false};
|
|
scope.selectStyle(selectedStyle);
|
|
expect(scope.selectedStyle).toEqual(selectedStyle);
|
|
|
|
var selectedStyle = {styles: "text-decoration: line-through; font-weight: 500; font-style: normal;",isExpanded:false};
|
|
scope.selectedStyle = {styles: "text-decoration': line-through; font-weight: 500; font-style: normal;",isExpanded:false};
|
|
|
|
scope.selectStyle(selectedStyle);
|
|
expect(scope.selectedStyle).toEqual(selectedStyle);
|
|
|
|
var selectedStyle = {isExpanded:true};
|
|
scope.selectStyle(selectedStyle);
|
|
expect(scope.selectedStyle).toEqual({});
|
|
});
|
|
|
|
it(' should run addStyle method and set scope.isDirtyState ', function() {
|
|
expect(scope.selected_css ).toBeDefined();
|
|
scope.additional = {style: 'background-position: -297px 0;width: 296px;height: 282px;'};
|
|
expect(scope.additional ).toEqual({style: 'background-position: -297px 0;width: 296px;height: 282px;'});
|
|
expect(scope.isDirtyState ).toBeFalsy();
|
|
|
|
|
|
var taskTemplate = new TaskTemplateVO();
|
|
taskTemplate.templateObject = {'styles':[scope.selectedStyle] };
|
|
scope.selectTemplate(taskTemplate);
|
|
scope.addStyle();
|
|
|
|
expect(scope.isDirtyState).toBeTruthy();
|
|
|
|
});
|
|
|
|
it(' should run updateElement method and add span', function() {
|
|
|
|
scope.updateElement('');
|
|
expect(scope.selectedStyle.element).toEqual('');
|
|
|
|
scope.updateElement('span');
|
|
expect(scope.selectedStyle.element).toEqual('span');
|
|
|
|
});
|
|
|
|
it(' should run updateFont method and set font ', function() {
|
|
|
|
scope.updateFont();
|
|
expect(scope.selected_css.fontFamily.label).toEqual('');
|
|
expect(scope.selected_css.fontFamily.value).toEqual('');
|
|
|
|
scope.updateFont({label:'Arial', value:'Arial'});
|
|
expect(scope.selected_css.fontFamily.label).toEqual('Arial');
|
|
expect(scope.selected_css.fontFamily.value).toEqual('Arial');
|
|
|
|
});
|
|
|
|
|
|
it(' should run updateFontSize method ', function() {
|
|
scope.updateFontSize();
|
|
expect(scope.selected_css.fontSize.label).toEqual('');
|
|
expect(scope.selected_css.fontSize.value).toEqual('');
|
|
|
|
scope.updateFontSize({label:'12pt', value:'12pt'});
|
|
expect(scope.selected_css.fontSize.label).toEqual('12pt');
|
|
expect(scope.selected_css.fontSize.value).toEqual('12pt');
|
|
|
|
});
|
|
|
|
|
|
it(' should run updateFontWeight method ', function() {
|
|
scope.selected_css.fontWeight.bold = '';
|
|
scope.updateFontWeight();
|
|
expect(scope.selected_css.fontWeight.value).toEqual('');
|
|
|
|
scope.selected_css.fontWeight.bold = 'bold';
|
|
scope.updateFontWeight();
|
|
expect(scope.selected_css.fontWeight.value).toEqual('bold');
|
|
|
|
});
|
|
|
|
it(' should run updateFontStyle method ', function() {
|
|
|
|
scope.updateFontStyle();
|
|
scope.selected_css.fontStyle.italic = '';
|
|
scope.updateFontStyle();
|
|
expect(scope.selected_css.fontStyle.value).toEqual('');
|
|
|
|
scope.selected_css.fontStyle.italic = 'italic';
|
|
scope.updateFontStyle();
|
|
expect(scope.selected_css.fontStyle.value).toEqual('italic');
|
|
|
|
});
|
|
|
|
it(' should run updateTextDecoration method ', function() {
|
|
scope.selected_css.textDecoration.underline = false;
|
|
scope.updateTextDecoration();
|
|
|
|
scope.selected_css.textDecoration.underline = true;
|
|
scope.updateTextDecoration();
|
|
expect(scope.selected_css.textDecoration.value).toEqual('underline');
|
|
|
|
scope.selected_css.textDecoration.lineThrough = false;
|
|
scope.updateTextDecoration();
|
|
|
|
scope.selected_css.textDecoration.lineThrough = true;
|
|
scope.updateTextDecoration();
|
|
expect(scope.selected_css.textDecoration.value).toEqual('underline line-through');
|
|
|
|
|
|
});
|
|
|
|
it(' should run update_css method ', function() {
|
|
scope.update_css();
|
|
|
|
});
|
|
|
|
it(' should run saveStyles method ', function() {
|
|
|
|
var taskTemplate = new TaskTemplateVO();
|
|
expect(scope.selectedTemplate).toEqual({});
|
|
taskTemplate.templateObject = {'styles':[scope.selectedStyle] };
|
|
|
|
scope.selectTemplate(taskTemplate);
|
|
scope.saveStyles();
|
|
|
|
});
|
|
|
|
it(' should run discard method ', function() {
|
|
|
|
scope.discard();
|
|
|
|
});
|
|
|
|
|
|
|
|
}); |