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
|
/* bender-tags: editor */
/* bender-ckeditor-plugins: dialog,button,forms,htmlwriter,toolbar */
/* bender-include: _helpers/tools.js */
/* global formsTools */
var assertRequiredAttribute = formsTools.assertRequiredAttribute;
bender.editor = {
config: {
autoParagraph: false
}
};
bender.test( {
'test fill basic fields': function() {
var bot = this.editorBot;
bot.dialog( 'select', function( dialog ) {
dialog.setValueOf( 'info', 'txtName', 'name' );
dialog.setValueOf( 'info', 'txtValue', 'value' );
dialog.setValueOf( 'info', 'txtSize', '8' );
dialog.setValueOf( 'info', 'required', 'required' );
dialog.setValueOf( 'info', 'chkMulti', 'checked' );
dialog.getButton( 'ok' ).click();
// IE needs delay as it runs asynchronous code in dialog's onOk.
wait( function() {
assert.isMatching( '<select multiple="(true|multiple)" name="name" required="required" size="8"></select>', bot.getData( false, true ) );
}, 10 );
} );
},
'test empty basic fields': function() {
var bot = this.editorBot;
bot.setHtmlWithSelection( '[<select multiple="true" name="name" required="required" size="8"></select>]' );
bot.dialog( 'select', function( dialog ) {
assert.areSame( 'name', dialog.getValueOf( 'info', 'txtName' ) );
assert.areSame( '', dialog.getValueOf( 'info', 'txtValue' ) );
assert.areSame( '8', dialog.getValueOf( 'info', 'txtSize' ) );
assert.areSame( true, dialog.getValueOf( 'info', 'required' ) );
assert.areSame( true, dialog.getValueOf( 'info', 'chkMulti' ) );
dialog.setValueOf( 'info', 'txtName', '' );
dialog.setValueOf( 'info', 'txtValue', '' );
dialog.setValueOf( 'info', 'txtSize', '' );
dialog.setValueOf( 'info', 'required', '' );
dialog.setValueOf( 'info', 'chkMulti', '' );
dialog.getButton( 'ok' ).click();
assert.areSame( '<select></select>', bot.getData( false, true ) );
} );
},
'test required attribute collapsed': assertRequiredAttribute( {
html: '[<select required></select>]',
type: 'select',
expected: true
} ),
'test required attribute without value': assertRequiredAttribute( {
html: '[<select required=""></select>]',
type: 'select',
expected: true
} ),
'test required attribute with value `required`': assertRequiredAttribute( {
html: '[<select required="required"></select>]',
type: 'select',
expected: true
} ),
'test required attribute absent': assertRequiredAttribute( {
html: '[<select></select>]',
type: 'select',
expected: false
} ),
'test required attribute with invalid value': assertRequiredAttribute( {
html: '[<select required="any value other than empty string or required"></select>]',
type: 'select',
expected: true
} )
} );
|