Make WordPress Core

Ticket #26620: 26620.diff

File 26620.diff, 2.1 KB (added by jorbin, 12 years ago)

Unit Test

  • src/wp-admin/js/word-count.js

     
    2626                        t.block = 1;
    2727
    2828                        setTimeout( function() {
     29                                debugger;
    2930                                if ( tx ) {
    3031                                        tx = tx.replace( t.settings.strip, ' ' ).replace( / | /gi, ' ' );
    3132                                        tx = tx.replace( t.settings.clean, '' );
  • 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

     
     1var wordCountL10n;
     2jQuery( 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});