See https://www.mediawiki.org/wiki/Reading/Web/QUnit_test_guidelines
Many of the tests in MobileFrontend and perhaps some in Popups use $.Deferred() to wait for an asynchronous result to assert. This works well but assert.async() seems preferable as a promise does not need to be returned from the test and an unnecessary direct dependency on jQuery is avoided.
Consider the following example:
QUnit.test( 'checking bad reference', function ( assert ) { var done = $.Deferred(); this.referencesGateway.getReference( '#cite_note-bad', this.page ).fail( function ( err ) { assert.ok( err === ReferencesGateway.ERROR_NOT_EXIST, 'When bad id given false returned.' ); done.resolve(); } ); return done; } );
Now with assert.async():
QUnit.test( 'checking bad reference', function ( assert ) { var done = assert.async(); this.referencesGateway.getReference( '#cite_note-bad', this.page ).fail( function ( err ) { assert.ok( err === ReferencesGateway.ERROR_NOT_EXIST, 'When bad id given false returned.' ); done(); } ); } );
Acceptance Criteria
- All assertion promises use assert.async() instead of Deferreds.
- rg '\$.Deferred\(\)' tests/ only shows mocked results