Ticket #26620: 26620.2.diff
| File 26620.2.diff, 2.6 KB (added by , 12 years ago) |
|---|
-
src/wp-admin/js/word-count.js
30 30 tx = tx.replace( t.settings.strip, ' ' ).replace( / | /gi, ' ' ); 31 31 tx = tx.replace( t.settings.clean, '' ); 32 32 tx.replace( t.settings[type], function(){tc++;} ); 33 34 // in the text editor, using word counting regex, when the last charector is a word charector, add one 35 if ( ('.tmce-active').length !== 0 && type == 'w' && tx.charAt(tx.length-1).match(/\w/) ) 36 tc++ 37 33 38 } 34 39 w.html(tc.toString()); 35 40 -
tests/qunit/index.html
14 14 15 15 <!-- Tested files --> 16 16 <script src="../../src/wp-admin/js/password-strength-meter.js"></script> 17 <script src="../../src/wp-admin/js/word-count.js"></script> 17 18 <script src="../../src/wp-includes/js/shortcode.js"></script> 18 19 19 20 <!-- Unit tests --> 20 21 <script src="wp-admin/js/password-strength-meter.js"></script> 22 <script src="wp-admin/js/word-count.js"></script> 21 23 <script src="wp-includes/js/shortcode.js"></script> 22 24 23 25 </head> … … 27 29 <h2 id="qunit-banner"></h2> 28 30 <h2 id="qunit-userAgent"></h2> 29 31 <ol id="qunit-tests"></ol> 30 <div id="qunit-fixture"></div> 32 <div id="qunit-fixture"> 33 <span class='word-count'></span> 34 </div> 31 35 </div> 32 36 </body> 33 37 </html> -
tests/qunit/wp-admin/js/word-count.js
1 var wordCountL10n; 2 jQuery( function() { 3 module( 'word-count' ); 4 5 // This is an async test since it involves testing dom manipulation 6 asyncTest('wpWordCount should set .word-count with the correct number of words for english language words', function(){ 7 wordCountL10n = 'w' 8 wpWordCount.wc('This is some content. It should be ten words long.'); 9 setTimeout(function(){ 10 // http://core.trac.wordpress.org/ticket/6991 11 equal(10, parseInt( jQuery('.word-count').html(), 10 ), 12 'the string "This is some content. It should be ten words long." shows 10'); 13 start(); 14 }, 100) 15 16 }); 17 18 });