tests: Remove use of QUnit 1.x setup()/teardown()

No longer supported upstream. Was kept compatible via MW core
testrunner.js, which I'd like to phase out so that our custom wrapper
can be removed, and thus other features like `QUnit.module.skip()`
become available.

While at it, also convert the file from an ad-hoc closure to using
the QUnit.module() scope and hooks object, as per
<https://api.qunitjs.com/QUnit/module/>.

Bug: T250045
Change-Id: I8c04c56cf5eec3f19ef12a803a192cd824b82f81
This commit is contained in:
Timo Tijhof 2022-05-03 01:07:28 +02:00
parent 9fa65ba1ed
commit 17fec690b0

View file

@ -1,14 +1,12 @@
( function () { QUnit.module( 'ext.wikiEditor.toolbar', function ( hooks ) {
QUnit.module( 'ext.wikiEditor.toolbar', QUnit.newMwEnvironment( { hooks.beforeEach( function () {
setup: function () {
var $target = $( '<textarea>' ) var $target = $( '<textarea>' )
.attr( 'id', 'wpTextBox1' ) .attr( 'id', 'wpTextBox1' )
.appendTo( '#qunit-fixture' ); .appendTo( '#qunit-fixture' );
this.$target = $target; this.$target = $target;
$target.wikiEditor( 'addModule', 'toolbar' ); $target.wikiEditor( 'addModule', 'toolbar' );
this.$ui = $target.data( 'wikiEditor-context' ).$ui; this.$ui = $target.data( 'wikiEditor-context' ).$ui;
} } );
} ) );
QUnit.test( 'Toolbars', function ( assert ) { QUnit.test( 'Toolbars', function ( assert ) {
// Add toolbar section // Add toolbar section
@ -284,4 +282,4 @@
assert.strictEqual( this.$ui.find( '*[rel="info"].section' ).length, 0, 'After removing booklet section' ); assert.strictEqual( this.$ui.find( '*[rel="info"].section' ).length, 0, 'After removing booklet section' );
} ); } );
}() ); } );