mediawiki-extensions-Thanks/tests/qunit/test_ext.thanks.mobilediff.js
jdlrobson e02c334880 Add tests for rendering of thanks button on mobile diff page
This has broken many times and I want this test to ensure its protection
in future.

Bug: T86687
Change-Id: Iea01c5c7c1ba00de47182521eeba86c8aef03522
2015-01-28 12:48:08 -08:00

23 lines
758 B
JavaScript

( function ( $ ) {
QUnit.module( 'Thanks mobilediff' );
QUnit.test( 'render button for logged in users', 1, function ( assert ) {
var $container = $( '<div>' ),
$user = $( '<div>' ).data( 'user-name', 'jon' )
.data( 'revision-id', 1 )
.data( 'user-gender', 'male' );
mw.thanks._mobileDiffInit( $user, $container );
assert.strictEqual( $container.find( 'button' ).length, 1, 'Thanks button was created.' );
} );
QUnit.test( 'Do not render button for anon users', 1, function ( assert ) {
var $container = $( '<div>' ),
$user = $( '<div class="mw-mf-anon">' );
mw.thanks._mobileDiffInit( $user, $container );
assert.strictEqual( $container.find( 'button' ).length, 0, 'No thanks button was created.' );
} );
}( jQuery ) );