TinyMCE: wptextpattern: make tests ~2x faster
* Reuse the same instance for all tests in the module. * Run without CSS (skin). * Less typing. See #31441. git-svn-id: https://develop.svn.wordpress.org/trunk@32706 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ea5ba64400
commit
11de1cedaa
@ -1,5 +1,6 @@
|
|||||||
( function( $, QUnit, tinymce, _type, setTimeout ) {
|
( function( $, QUnit, tinymce, _type, setTimeout ) {
|
||||||
var editor;
|
var editor,
|
||||||
|
count = 0;
|
||||||
|
|
||||||
if ( tinymce.Env.ie && tinymce.Env.ie < 9 ) {
|
if ( tinymce.Env.ie && tinymce.Env.ie < 9 ) {
|
||||||
return;
|
return;
|
||||||
@ -31,35 +32,48 @@
|
|||||||
|
|
||||||
QUnit.module( 'tinymce.plugins.wptextpattern', {
|
QUnit.module( 'tinymce.plugins.wptextpattern', {
|
||||||
beforeEach: function( assert ) {
|
beforeEach: function( assert ) {
|
||||||
var done = assert.async();
|
var done;
|
||||||
|
|
||||||
$( '#qunit-fixture' ).append( '<textarea id="editor">' );
|
if ( ! editor ) {
|
||||||
|
done = assert.async();
|
||||||
|
|
||||||
|
$( document.body ).append( '<textarea id="editor">' );
|
||||||
|
|
||||||
tinymce.init( {
|
tinymce.init( {
|
||||||
selector: '#editor',
|
selector: '#editor',
|
||||||
|
skin: false,
|
||||||
plugins: 'wptextpattern',
|
plugins: 'wptextpattern',
|
||||||
init_instance_callback: function() {
|
init_instance_callback: function() {
|
||||||
editor = arguments[0];
|
editor = arguments[0];
|
||||||
editor.focus();
|
editor.focus();
|
||||||
editor.selection.setCursorLocation();
|
editor.selection.setCursorLocation();
|
||||||
setTimeout( done );
|
done();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
} else {
|
||||||
|
editor.setContent( '' );
|
||||||
|
editor.selection.setCursorLocation();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
afterEach: function() {
|
afterEach: function( assert ) {
|
||||||
|
count++;
|
||||||
|
|
||||||
|
if ( count === assert.test.module.tests.length ) {
|
||||||
editor.remove();
|
editor.remove();
|
||||||
|
$( '#editor' ).remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( 'Unordered list.', function( assert ) {
|
QUnit.test( 'Unordered list.', function( assert ) {
|
||||||
type( '* test', function() {
|
type( '* a', function() {
|
||||||
assert.equal( editor.getContent(), '<ul>\n<li>test</li>\n</ul>' );
|
assert.equal( editor.getContent(), '<ul>\n<li>a</li>\n</ul>' );
|
||||||
}, assert.async() );
|
}, assert.async() );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( 'Ordered list.', function( assert ) {
|
QUnit.test( 'Ordered list.', function( assert ) {
|
||||||
type( '1. test', function() {
|
type( '1. a', function() {
|
||||||
assert.equal( editor.getContent(), '<ol>\n<li>test</li>\n</ol>' );
|
assert.equal( editor.getContent(), '<ol>\n<li>a</li>\n</ol>' );
|
||||||
}, assert.async() );
|
}, assert.async() );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
@ -94,8 +108,8 @@
|
|||||||
editor.setContent( '<p>* test</p>' );
|
editor.setContent( '<p>* test</p>' );
|
||||||
editor.selection.setCursorLocation( editor.$( 'p' )[0].firstChild, 6 );
|
editor.selection.setCursorLocation( editor.$( 'p' )[0].firstChild, 6 );
|
||||||
|
|
||||||
type( ' test', function() {
|
type( ' a', function() {
|
||||||
assert.equal( editor.getContent(), '<p>* test test</p>' );
|
assert.equal( editor.getContent(), '<p>* test a</p>' );
|
||||||
}, assert.async() );
|
}, assert.async() );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user