| | 18 | to: |
| | 19 | |
| | 20 | {{{ |
| | 21 | 'check if font size combo loads proper stylesheet': function() { |
| | 22 | this.editorBot.combo( 'FontSize', function( combo ) { |
| | 23 | var isPresent = searchForStylesheet( combo ); |
| | 24 | |
| | 25 | assert.isTrue( isPresent, 'check if stylesheet is present in font size combo\'s iframe' ); |
| | 26 | } ); |
| | 27 | }, |
| | 28 | }}} |
| | 29 | |
| | 30 | `isPresent` is a different case here as |
| | 31 | |
| | 32 | {{{ |
| | 33 | var isPresent = searchForStylesheet( combo ); |
| | 34 | assert.isTrue( isPresent, 'check if stylesheet is present in font size combo\'s iframe' ); |
| | 35 | }}} |
| | 36 | |
| | 37 | might actually be more readable than: |
| | 38 | |
| | 39 | {{{ |
| | 40 | assert.isTrue( searchForStylesheet( combo ), 'check if stylesheet is present in font size combo\'s iframe' ); |
| | 41 | }}} |
| | 42 | |
| | 43 | So I can see how it might improve readability - that being said I'm fine with one way or another in this particular case. |
| | 44 | |
| | 45 | * Stay DRY, extract `searchForStylesheet` function to `_helper/tools.js` in your tests directory. |
| | 46 | * Utilize advantage of our `CKEDITOR.dom.*` wrappers, [https://github.com/cksource/ckeditor-dev/blob/t/13771/tests/tickets/13771/1.js#L62-L65 initial lines] in `searchForStylesheet` method might be simplified down to: |
| | 47 | |
| | 48 | {{{ |
| | 49 | var frameDoc = combo._.panel.element.getFirst().getFrameDocument(), |
| | 50 | stylesheets = frameDoc.find( 'link[rel="stylesheet"]' ).$; |
| | 51 | }}} |
| | 52 | |
| | 53 | Not only that, using this you no longer need to [https://github.com/cksource/ckeditor-dev/blob/t/13771/tests/tickets/13771/1.js#L72-L73 check rel attribute]. |
| | 54 | |
| | 55 | Then you can actually think about rewriting it to: |
| | 56 | |
| | 57 | {{{ |
| | 58 | function searchForStylesheet( combo ) { |
| | 59 | var frameDoc = combo._.panel.element.getFirst().getFrameDocument(); |
| | 60 | // Look for any stylesheet link elems that end with desired CSS file. |
| | 61 | return Boolean( frameDoc.findOne('link[rel="stylesheet"][href$="contents.css"]') ); |
| | 62 | } |
| | 63 | }}} |
| | 64 | |
| | 65 | I'd suggest you just to go through most important namespaces now: |
| | 66 | |
| | 67 | * [http://docs.ckeditor.com/#!/api/CKEDITOR.dom.node CKEDITOR.dom.node] |
| | 68 | * [http://docs.ckeditor.com/#!/api/CKEDITOR.dom.element CKEDITOR.dom.element] (this time use show dropdown and exclude Inherited, as you don't need to read node methods again :)) |
| | 69 | * [http://docs.ckeditor.com/#!/api/CKEDITOR.dom.event CKEDITOR.dom.event] |
| | 70 | * [http://docs.ckeditor.com/#!/api/CKEDITOR.dom.document CKEDITOR.dom.document] |
| | 71 | * [http://docs.ckeditor.com/#!/api/CKEDITOR.dom.window CKEDITOR.dom.window] |
| | 72 | |
| | 73 | Then read other `CKEDITOR.dom.*` member docs the other day! :) |
| | 74 | |
| | 75 | * It's great that you've thought about multiple editor creators! You can do it way simpler, without code duplication. Use `bender.editors` property, for example usage see [https://github.com/cksource/ckeditor-dev/blob/t/13771/tests/plugins/table/table.js#L7-L15 table plugin tests]. |