1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
/* bender-tags: editor,dialog */
/* bender-ckeditor-plugins: forms,toolbar */
/* bender-include: _helpers/tools.js */
/* global formsTools */
var assertRequiredAttribute = formsTools.assertRequiredAttribute;
bender.editor = {
config: {
autoParagraph: false
}
};
bender.test( {
test_createFillFields: function() {
var editorBot = this.editorBot;
editorBot.setHtmlWithSelection( '<p>^</p>' );
editorBot.dialog( 'textarea', function( dialog ) {
dialog.setValueOf( 'info', '_cke_saved_name', 'test_textarea' );
dialog.setValueOf( 'info', 'cols', 80 );
dialog.setValueOf( 'info', 'rows', 5 );
dialog.setValueOf( 'info', 'value', 'Some testing value.' );
dialog.setValueOf( 'info', 'required', 'checked' );
dialog.getButton( 'ok' ).click();
assert.areSame( '<p><textarea cols="80" name="test_textarea" required="required" rows="5">some testing value.</textarea></p>', editorBot.getData( true ) );
} );
},
test_emptyFields: function() {
var bot = this.editorBot;
bot.setHtmlWithSelection( '[<textarea cols="80" name="test_textarea" required="required" rows="5">some testing value.</textarea>]' );
bot.dialog( 'textarea', function( dialog ) {
assert.areSame( 'test_textarea', dialog.getValueOf( 'info', '_cke_saved_name' ) );
assert.areSame( true, dialog.getValueOf( 'info', 'required' ) );
assert.areSame( '80', dialog.getValueOf( 'info', 'cols' ) );
assert.areSame( '5', dialog.getValueOf( 'info', 'rows' ) );
dialog.setValueOf( 'info', '_cke_saved_name', '' );
dialog.setValueOf( 'info', 'rows', '' );
dialog.setValueOf( 'info', 'cols', '' );
dialog.setValueOf( 'info', 'required', '' );
dialog.getButton( 'ok' ).click();
assert.areSame( '<textarea>some testing value.</textarea>', bot.getData( false, true ) );
} );
},
test_createSimple: function() {
var editorBot = this.editorBot;
editorBot.setHtmlWithSelection( '<p>^</p>' );
editorBot.dialog( 'textarea', function( dialog ) {
dialog.getButton( 'ok' ).click();
assert.areSame( '<p><textarea></textarea></p>', editorBot.getData() );
} );
},
test_specialValues: function() {
var values = [
'<HTML> content: <textarea>sample</textarea> tag.',
'Line 1\nLine 2',
' Spaces before.',
'Spaces after. '
],
editorBot = this.editorBot,
currentIndex = 0;
function testValue( index ) {
var value = values[ index ];
if ( !value )
return;
editorBot.setHtmlWithSelection( '<p>^</p>' );
editorBot.dialog( 'textarea', function( dialog ) {
dialog.setValueOf( 'info', 'value', value );
dialog.getButton( 'ok' ).click();
assert.areSame( '<p><textarea>' + value.replace( /</g, '<' ).replace( />/g, '>' ) + '</textarea></p>', editorBot.getData().replace( '\r\n', '\n' ) );
testValue.call( this, ++currentIndex );
} );
}
// Start testing.
testValue.call( this, 0 );
},
// (#2423)
'test dialog model during textarea creation': function() {
var bot = this.editorBot,
editor = this.editor;
bot.setData( '', function() {
bot.dialog( 'textarea', function( dialog ) {
assert.isNull( dialog.getModel( editor ) );
assert.areEqual( CKEDITOR.dialog.CREATION_MODE, dialog.getMode( editor ) );
dialog.hide();
} );
} );
},
// (#2423)
'test dialog model with existing textarea': function() {
// (#3700)
if ( CKEDITOR.env.ie && CKEDITOR.env.version === 8 ) {
assert.ignore();
}
var bot = this.editorBot,
editor = this.editor;
bot.setData( '<textarea>test</textarea>', function() {
bot.dialog( 'textarea', function( dialog ) {
var textarea = editor.editable().findOne( 'textarea' );
editor.getSelection().selectElement( textarea );
assert.areEqual( textarea, dialog.getModel( editor ) );
assert.areEqual( CKEDITOR.dialog.EDITING_MODE, dialog.getMode( editor ) );
dialog.hide();
} );
} );
},
'test required attribute collapsed': assertRequiredAttribute( {
html: '[<textarea required></textarea>]',
type: 'textarea',
expected: true
} ),
'test required attribute without value': assertRequiredAttribute( {
html: '[<textarea required=""></textarea>]',
type: 'textarea',
expected: true
} ),
'test required attribute with value `required`': assertRequiredAttribute( {
html: '[<textarea required="required"></textarea>]',
type: 'textarea',
expected: true
} ),
'test required attribute absent': assertRequiredAttribute( {
html: '[<textarea></textarea>]',
type: 'textarea',
expected: false
} ),
'test required attribute with invalid value': assertRequiredAttribute( {
html: '[<textarea required="any value other than empty string or required"></textarea>]',
type: 'textarea',
expected: true
} )
} );
|