Make WordPress Core

Ticket #26620: 26620.3.diff

File 26620.3.diff, 2.5 KB (added by jorbin, 12 years ago)
  • src/wp-admin/js/word-count.js

     
    2727
    2828                        setTimeout( function() {
    2929                                if ( tx ) {
     30                                        // pad our string to prevent errors where string ends with a letter in text mode
     31                                        tx += ' ';
    3032                                        tx = tx.replace( t.settings.strip, ' ' ).replace( / | /gi, ' ' );
    3133                                        tx = tx.replace( t.settings.clean, '' );
    3234                                        tx.replace( t.settings[type], function(){tc++;} );
  • tests/qunit/index.html

     
    1414
    1515  <!-- Tested files -->
    1616  <script src="../../src/wp-admin/js/password-strength-meter.js"></script>
     17  <script src="../../src/wp-admin/js/word-count.js"></script>
    1718  <script src="../../src/wp-includes/js/shortcode.js"></script>
    1819
    1920  <!-- Unit tests -->
    2021  <script src="wp-admin/js/password-strength-meter.js"></script>
     22  <script src="wp-admin/js/word-count.js"></script>
    2123  <script src="wp-includes/js/shortcode.js"></script>
    2224
    2325</head>
     
    2729    <h2 id="qunit-banner"></h2>
    2830    <h2 id="qunit-userAgent"></h2>
    2931    <ol id="qunit-tests"></ol>
    30     <div id="qunit-fixture"></div>
     32    <div id="qunit-fixture">
     33                <span class='word-count'></span>       
     34        </div>
    3135  </div>
    3236</body>
    3337</html>
  • tests/qunit/wp-admin/js/word-count.js

     
     1/* global wpWordCount, jQuery */
     2var wordCountL10n;
     3jQuery( function() {
     4        module( 'word-count' );
     5
     6        // This is an async test since it involves testing dom  manipulation
     7        asyncTest('wpWordCount should set .word-count with the correct number of words for english language words', function(){
     8                wordCountL10n = 'w';
     9                wpWordCount.wc('This is some content. It should be ten words long.');
     10                setTimeout(function(){
     11                        // http://core.trac.wordpress.org/ticket/6991
     12                        equal(10, parseInt( jQuery('.word-count').html(), 10 ),
     13                                'the string "This is some content. It should be ten words long." shows 10');
     14                        start();
     15                }, 100);
     16
     17        });
     18
     19});