2015-07-16 01:47:02 +02:00
|
|
|
( function( QUnit, wordCounter ) {
|
2015-06-19 12:34:59 +02:00
|
|
|
QUnit.module( 'word-count' );
|
|
|
|
|
|
|
|
QUnit.test( 'All.', function( assert ) {
|
2015-07-16 01:47:02 +02:00
|
|
|
_.each( [
|
2015-06-19 12:34:59 +02:00
|
|
|
{
|
|
|
|
message: 'Basic test.',
|
|
|
|
string: 'one two three',
|
2015-07-16 01:47:02 +02:00
|
|
|
words: 3,
|
|
|
|
characters: 11,
|
|
|
|
all: 13
|
2015-06-19 12:34:59 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
message: 'HTML tags.',
|
|
|
|
string: 'one <em class="test">two</em><br />three',
|
2015-07-16 01:47:02 +02:00
|
|
|
words: 3,
|
|
|
|
characters: 11,
|
|
|
|
all: 12
|
2015-06-19 12:34:59 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
message: 'Line breaks.',
|
|
|
|
string: 'one\ntwo\nthree',
|
2015-07-16 01:47:02 +02:00
|
|
|
words: 3,
|
|
|
|
characters: 11,
|
|
|
|
all: 11
|
2015-06-19 12:34:59 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
message: 'Encoded spaces.',
|
|
|
|
string: 'one two three',
|
2015-07-16 01:47:02 +02:00
|
|
|
words: 3,
|
|
|
|
characters: 11,
|
|
|
|
all: 13
|
2015-06-19 12:34:59 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
message: 'Punctuation.',
|
|
|
|
string: 'It\'s two three... 4?',
|
2015-07-16 01:47:02 +02:00
|
|
|
words: 3,
|
|
|
|
characters: 11,
|
|
|
|
all: 14
|
2015-06-19 12:34:59 +02:00
|
|
|
}
|
2015-07-16 01:47:02 +02:00
|
|
|
], function( test ) {
|
|
|
|
_.each( [ 'words', 'characters', 'all' ], function( type ) {
|
|
|
|
assert.equal( wordCounter.count( test.string, type ), test[ type ], test.message + ' (' + type + ')' );
|
|
|
|
} );
|
|
|
|
} );
|
2015-06-19 12:34:59 +02:00
|
|
|
} );
|
2015-07-16 01:47:02 +02:00
|
|
|
} )( window.QUnit, new window.wp.utils.WordCounter() );
|