Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/56322
Change subject: Provide greater expect-ations (fix breaking tests)
......................................................................
Provide greater expect-ations (fix breaking tests)
Make use of expect in qunit tests
(see change I214b3d4da46f3f3bb0fcde313ac2d82439e40e3c)
Change-Id: I545cd1520ac4b0f945b71f76479473bcebe66573
---
M tests/js/common/mf-navigation.js
M tests/js/specials/mobilediff.js
M tests/js/specials/uploads.js
M tests/js/test_application.js
M tests/js/test_banner.js
M tests/js/test_beta_opensearch.js
M tests/js/test_eventemitter.js
M tests/js/test_mf-api.js
M tests/js/test_mf-edit.js
M tests/js/test_mf-history.js
M tests/js/test_mf-last-modified.js
M tests/js/test_mf-oop.js
M tests/js/test_mf-photo.js
M tests/js/test_mf-view.js
M tests/js/test_mf-watchstar.js
M tests/js/test_references.js
M tests/js/test_settings.js
M tests/js/test_toggle.js
M tests/js/widgets/test_progress-bar.js
19 files changed, 106 insertions(+), 36 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/22/56322/1
diff --git a/tests/js/common/mf-navigation.js b/tests/js/common/mf-navigation.js
index 378c5f6..27b9cf9 100644
--- a/tests/js/common/mf-navigation.js
+++ b/tests/js/common/mf-navigation.js
@@ -1,8 +1,9 @@
-( function( nav, $ ) {
+( function( nav, $, Q ) {
module( 'MobileFrontend: mf-navigation.js', {} );
test( 'Simple overlay', function() {
+ Q.expect( 2 );
var overlay = new nav.Overlay( { heading: '<h2>Title</h2>', content:
'Text' } );
overlay.show();
strictEqual( overlay.$el[0].parentNode, document.body, 'In DOM' );
@@ -10,6 +11,7 @@
} );
test( 'HTML overlay', function() {
+ Q.expect( 1 );
var overlay = new nav.Overlay( {
heading: '<div>Awesome: <input></div>',
content: '<div class="content">YO</div>'
@@ -18,6 +20,7 @@
} );
test( 'Close overlay', function() {
+ Q.expect( 1 );
var overlay = new nav.Overlay( { heading: '<h2>Title</h2>', content:
'Text' } );
overlay.show();
overlay.hide();
@@ -25,6 +28,7 @@
} );
test( 'Stacked overlays', function() {
+ Q.expect( 6 );
var overlay = new nav.Overlay( { heading: 'Overlay 1', content: 'Text'
} ),
overlayTwo = new nav.Overlay( { heading: 'Overlay 2', content:
'Text <button class="cancel">cancel</button>',
parent: overlay } );
@@ -44,4 +48,4 @@
} );
-} )( mw.mobileFrontend.require( 'navigation' ), jQuery );
+} )( mw.mobileFrontend.require( 'navigation' ), jQuery, QUnit );
diff --git a/tests/js/specials/mobilediff.js b/tests/js/specials/mobilediff.js
index e209abf..04101cc 100644
--- a/tests/js/specials/mobilediff.js
+++ b/tests/js/specials/mobilediff.js
@@ -1,4 +1,4 @@
-( function( M, $ ) {
+( function( M, $, Q ) {
var m = M.require( 'diff' );
@@ -25,9 +25,10 @@
]
];
+ Q.expect( testCases.length );
$.each( testCases, function( i, test ) {
strictEqual( m.makePrettyDiff( test[0] ).html(), test[1], 'Test
case ' + i );
} );
} );
-} )( mw.mobileFrontend, jQuery );
+} )( mw.mobileFrontend, jQuery, QUnit );
diff --git a/tests/js/specials/uploads.js b/tests/js/specials/uploads.js
index 25519d8..3410c69 100644
--- a/tests/js/specials/uploads.js
+++ b/tests/js/specials/uploads.js
@@ -1,4 +1,4 @@
-( function ( M, $ ) {
+( function ( M, $, Q ) {
var m = M.require( 'userGallery' );
module( 'MobileFrontend donate image' );
@@ -10,10 +10,11 @@
[ '==Foo 1==\nbar 1\n== {{int:filedesc}} ==\npicture of
dog\n==Foo 2==\nbar 2\n', 'picture of dog' ],
[ '== Yo ==\nother text', '' ]
];
+ Q.expect( tests.length );
$( tests ).each( function( i ) {
var val = m.extractDescription( this[0] );
strictEqual( val, this[1], 'test ' + i );
} );
} );
-}( mw.mobileFrontend, jQuery ) );
+}( mw.mobileFrontend, jQuery, QUnit ) );
diff --git a/tests/js/test_application.js b/tests/js/test_application.js
index f9e88de..5e69ae6 100644
--- a/tests/js/test_application.js
+++ b/tests/js/test_application.js
@@ -12,6 +12,7 @@
});
test("history.replaceHash", function() {
+ Q.expect( 1 );
MFE.history.replaceHash("#hash3");
strictEqual(window.location.hash, "#hash3", "the hash was set for the
first time");
});
@@ -20,6 +21,7 @@
module( 'MobileFrontend modules' );
test( 'define()', function() {
+ Q.expect( 1 );
MFE.define( 'testModule1', 'test module 1' );
Q.throws(
function() {
@@ -31,6 +33,7 @@
} );
test( 'require()', function() {
+ Q.expect( 2 );
Q.throws(
function() {
MFE.require( 'dummy' );
@@ -46,6 +49,7 @@
module( 'MobileFrontend common functions' );
test( '#getSessionId', function() {
+ Q.expect( 3 );
var sessionId = MFE.getSessionId();
strictEqual( typeof sessionId, 'string', 'session ID is a string' );
strictEqual( sessionId.length, 32, 'session ID is 32 chars long' );
diff --git a/tests/js/test_banner.js b/tests/js/test_banner.js
index 71d3553..60913a7 100644
--- a/tests/js/test_banner.js
+++ b/tests/js/test_banner.js
@@ -1,4 +1,4 @@
-( function ( $, MFEB, settings ) {
+( function ( $, MFEB, settings, Q ) {
var BANNER_COOKIE_NAME = "zero-rated-banner";
module("MobileFrontend banner.js: notifications", {
setup: function() {
@@ -13,6 +13,7 @@
});
test("MobileFrontend banner.js: dismiss notification", function() {
+ Q.expect( 5 );
var cookieStart, cookieEnd;
MFEB.init();
cookieStart = settings.getUserSetting( BANNER_COOKIE_NAME );
@@ -27,4 +28,4 @@
strictEqual($("#zero-rated-banner").is(":visible"), false, "banner
should now be hidden");
strictEqual(cookieEnd, "off", "banner now set for dismissal");
});
-}( jQuery, mw.mobileFrontend.require( 'banner' ), mw.mobileFrontend.settings )
);
+}( jQuery, mw.mobileFrontend.require( 'banner' ), mw.mobileFrontend.settings,
QUnit ) );
diff --git a/tests/js/test_beta_opensearch.js b/tests/js/test_beta_opensearch.js
index 6fde558..6e6d0b0 100644
--- a/tests/js/test_beta_opensearch.js
+++ b/tests/js/test_beta_opensearch.js
@@ -1,4 +1,4 @@
-(function ( $, MFE, MFEOS ) {
+(function ( $, MFE, MFEOS, Q ) {
module( 'MobileFrontend: mf-search.js - test highlight', {
setup: function() {
$( '<form id="mw-mf-searchForm"><input
id="mw-mf-search"></form>' ).appendTo( document.body );
@@ -11,11 +11,13 @@
});
test("no results", function() {
+ Q.expect( 1 );
MFEOS.writeResults([]);
strictEqual($("#results").text(), MFE.message(
'mobile-frontend-search-noresults' ) );
});
test("writeResults with highlighted text (case differs)", function() {
+ Q.expect( 3 );
var results = [
{ label: "Hello world", value: "/HelloWorld" },
{ label: "Hello kitty", value: "/HelloKitty" }
@@ -31,6 +33,7 @@
});
test("writeResults with highlighted text (case differs)", function() {
+ Q.expect( 1 );
var results = [
{ label: "Hello world", value: "/HelloWorld" },
{ label: "Hello kitty", value: "/HelloKitty" }
@@ -43,6 +46,7 @@
});
test("writeResults with highlighted text (special character &)",
function() {
+ Q.expect( 1 );
var results = [
{ label: "Belle & Sebastian", value: "/B1" },
{ label: "Belle & the Beast", value: "/B2" }
@@ -55,6 +59,7 @@
});
test("writeResults with highlighted text (special character ?)", function() {
+ Q.expect( 1 );
var results = [
{ label: "Title with ? in it", value: "/B1" }
], pageLink;
@@ -66,6 +71,7 @@
});
test("writeResults with highlighted text (safe)", function() {
+ Q.expect( 1 );
var results = [
{ label: "<script>alert('FAIL')</script> should be safe",
value: "/B1" }
], pageLink;
@@ -76,4 +82,4 @@
strictEqual($(pageLink).html(),
"<strong><script>alert('FAIL'</strong>)</script>
should be safe", "check the highlight is correct");
});
-}( jQuery, mw.mobileFrontend, mw.mobileFrontend.require( 'opensearch' ) ) );
+}( jQuery, mw.mobileFrontend, mw.mobileFrontend.require( 'opensearch' ), QUnit
) );
diff --git a/tests/js/test_eventemitter.js b/tests/js/test_eventemitter.js
index 4f78f58..b7c5f38 100644
--- a/tests/js/test_eventemitter.js
+++ b/tests/js/test_eventemitter.js
@@ -1,14 +1,15 @@
-( function( M ) {
+( function( M, Q ) {
var EventEmitter = M.require( 'eventemitter' );
module( 'MobileFrontend EventEmitter' );
test( '#on', function() {
+ Q.expect( 1 );
var e = new EventEmitter(), spy = sinon.spy();
e.on( 'testEvent', spy );
e.emit( 'testEvent', 'first', 2 );
ok( spy.calledWith( 'first', 2 ), 'run callback when event runs' );
} );
-}( mw.mobileFrontend ));
+}( mw.mobileFrontend, QUnit ) );
diff --git a/tests/js/test_mf-api.js b/tests/js/test_mf-api.js
index 534713b..241213c 100644
--- a/tests/js/test_mf-api.js
+++ b/tests/js/test_mf-api.js
@@ -1,4 +1,4 @@
-( function ( M, $ ) {
+( function ( M, $, Q ) {
var Api = M.require( 'api' ).Api, stub;
@@ -17,6 +17,7 @@
} );
test( '$.ajaxSetup()', function() {
+ Q.expect( 1 );
$.ajax( {
data: { test: 'test' }
} );
@@ -24,12 +25,14 @@
} );
test( 'default instance', function() {
+ Q.expect( 1 );
ok( M.require( 'api' ) instanceof Api, 'return default instance' );
} );
// FIXME: uncomment when https://bugzilla.wikimedia.org/show_bug.cgi?id=44921
is resolved
/*
test( 'progress event', function() {
+ Q.expect( 1 );
var spy = sinon.spy(),
api = new Api();
api.post().on( 'progress', spy );
@@ -55,6 +58,7 @@
} );
test( '#ajax', function() {
+ Q.expect( 1 );
this.api.ajax( {
falseBool: false,
trueBool: true,
@@ -74,6 +78,7 @@
} );
test( '#ajax, with FormData', function() {
+ Q.expect( 1 );
var data = new FormData();
// add a property that should not disappear
data.testBool = false;
@@ -82,16 +87,19 @@
} );
test( '#get', function() {
+ Q.expect( 1 );
this.api.get( { a: 1 } );
ok( $.ajax.calledWithMatch( { type: 'GET', data: { a: 1 } } ), 'call
with type: GET' );
} );
test( '#post', function() {
+ Q.expect( 1 );
this.api.post( { a: 1 } );
ok( $.ajax.calledWithMatch( { type: 'POST', data: { a: 1 } } ), 'call
with type: POST' );
} );
test( '#abort', function() {
+ Q.expect( 2 );
this.api.get( { a: 1 } );
this.api.post( { b: 2 } );
this.api.abort();
@@ -133,12 +141,14 @@
} );
test( '#getToken - successful edit token', function() {
+ Q.expect( 1 );
this.api.getToken( 'edit' ).done( function( token ) {
strictEqual( token, '123', 'Got token' );
} );
} );
test( '#getToken - load from cache', function() {
+ Q.expect( 2 );
this.api.getToken( 'edit' );
this.api.getToken( 'edit' ).done( function( token ) { // this comes via
cache
strictEqual( token, '123', 'Test for bad token name' );
@@ -148,27 +158,31 @@
} );
test( '#getToken - cors edit token', function() {
+ Q.expect( 1 );
this.api.getToken( 'watch', 'http://commons.wikimedia.org/w/api.php'
).done( function( token ) {
strictEqual( token, 'zyx', 'Correctly passed via cors' );
} );
} );
test( '#getToken - default to edit', function() {
+ Q.expect( 1 );
this.api.getToken().done( function( token ) {
strictEqual( token, '123', 'We get an edit token by default
(most common)' );
} );
} );
test( '#getToken - get anon token', function() {
+ Q.expect( 1 );
this.api.getToken( 'upload' ).fail( function( msg ) {
strictEqual( msg, 'Anonymous token.', 'No token given - user
must be anon' );
} );
} );
test( '#getToken - bad type of token', function() {
+ Q.expect( 1 );
this.api.getToken( 'rainbows' ).fail( function( msg ) {
strictEqual( msg, 'Bad token name.', 'Test for bad token name'
);
} );
} );
-}( mw.mobileFrontend, jQuery ) );
+}( mw.mobileFrontend, jQuery, QUnit ) );
diff --git a/tests/js/test_mf-edit.js b/tests/js/test_mf-edit.js
index 9391400..1e74d32 100644
--- a/tests/js/test_mf-edit.js
+++ b/tests/js/test_mf-edit.js
@@ -1,4 +1,4 @@
-( function ( $, m ) {
+( function ( $, m, Q ) {
module( 'MobileFrontend: mf-edit', {
setup: function() {
@@ -12,6 +12,7 @@
} );
test( 'concatTextAreas basic line', function() {
+ Q.expect( 1 );
var val = 'Test';
$( 'form#editform textarea' ).val( val );
m.init();
@@ -19,6 +20,7 @@
} );
test( 'concatTextAreas headings', function() {
+ Q.expect( 1 );
var val = 'Test\n\n==Hello World==\nHello';
$( 'form#editform textarea' ).val( val );
m.init();
@@ -26,6 +28,7 @@
} );
test( 'concatTextAreas headings 2', function() {
+ Q.expect( 1 );
var val = 'Test\n\n==1.0==\nText of 1.0\n===1.1===\nText of
1.1\n==2.0==\nText of 2.0';
$( 'form#editform textarea' ).val( val );
m.init();
@@ -33,6 +36,7 @@
} );
test( 'concatTextAreas headings 3', function() {
+ Q.expect( 1 );
var val = 'Test\n\n==1.0==\n\nText of 1.0\n\n===1.1===\n\nText of
1.1\n==2.0==\nText of 2.0';
$( 'form#editform textarea' ).val( val );
m.init();
@@ -40,4 +44,4 @@
} );
-} )( jQuery, mw.mobileFrontend.require( 'edit' ) );
+} )( jQuery, mw.mobileFrontend.require( 'edit' ), QUnit );
diff --git a/tests/js/test_mf-history.js b/tests/js/test_mf-history.js
index 9cce570..fdc6303 100644
--- a/tests/js/test_mf-history.js
+++ b/tests/js/test_mf-history.js
@@ -1,36 +1,42 @@
-( function( M ) {
+( function( M, Q ) {
module( 'MobileFrontend: mf-history.js', {} );
test( 'updateQueryStringParameter 1', function() {
+ Q.expect( 1 );
var val1 = M.history.updateQueryStringParameter( '/w/Foo?x=4', 'x',
'10' );
strictEqual( val1, '/w/Foo?x=10' );
} );
test( 'updateQueryStringParameter 2', function() {
+ Q.expect( 1 );
var val1 = M.history.updateQueryStringParameter( '/w/Foo', 'x', '10' );
strictEqual( val1, '/w/Foo?x=10' );
} );
test( 'updateQueryStringParameter 3', function() {
+ Q.expect( 1 );
var val1 = M.history.updateQueryStringParameter( '/w/Foo?y=4&x=4&z=10',
'x', '10' );
strictEqual( val1, '/w/Foo?y=4&x=10&z=10' );
} );
test( 'updateQueryStringParameter 3', function() {
+ Q.expect( 1 );
var val1 = M.history.updateQueryStringParameter( '/w/Foo?y=4', 'x',
'10' );
strictEqual( val1, '/w/Foo?y=4&x=10' );
} );
test( 'updateQueryStringParameter 4', function() {
+ Q.expect( 1 );
var val1 = M.history.updateQueryStringParameter( '/w/Foo?x=4', 'x',
'y=10' );
strictEqual( val1, '/w/Foo?x=y%3D10' );
} );
test( 'getArticleUrl with parameters', function() {
+ Q.expect( 2 );
sinon.stub( mw.config, 'get' ).withArgs( 'wgArticlePath' ).returns(
'/w/index.php/$1' );
strictEqual( M.history.getArticleUrl( 'Foo', {} ), '/w/index.php/Foo' );
strictEqual( M.history.getArticleUrl( 'Foo', { action: 'edit' } ),
'/w/index.php/Foo?action=edit' );
mw.config.get.restore();
} );
-} )( mw.mobileFrontend );
+} )( mw.mobileFrontend, QUnit );
diff --git a/tests/js/test_mf-last-modified.js
b/tests/js/test_mf-last-modified.js
index c57b876..05326ad 100644
--- a/tests/js/test_mf-last-modified.js
+++ b/tests/js/test_mf-last-modified.js
@@ -1,8 +1,9 @@
-( function( m ) {
+( function( m, Q ) {
module( 'MobileFrontend: mf-last-modified' );
test( 'timeAgo()', function() {
+ Q.expect( 8 );
deepEqual( m.timeAgo( 40 ), { value: 40, unit: 'seconds' } );
deepEqual( m.timeAgo( 149 ), { value: 2, unit: 'minutes' } );
deepEqual( m.timeAgo( 150 ), { value: 3, unit: 'minutes' } );
@@ -13,4 +14,4 @@
deepEqual( m.timeAgo( 102000000 ), { value: 3, unit: 'years' } );
} );
-} )( mw.mobileFrontend.require( 'last-modified' ) );
+} )( mw.mobileFrontend.require( 'last-modified' ), QUnit );
diff --git a/tests/js/test_mf-oop.js b/tests/js/test_mf-oop.js
index 3f8d5d4..013797d 100644
--- a/tests/js/test_mf-oop.js
+++ b/tests/js/test_mf-oop.js
@@ -1,10 +1,11 @@
-( function( M ) {
+( function( M, Q ) {
var oop = M.require( 'oop' );
module( 'MobileFrontend oop' );
test( '#extend', function() {
+ Q.expect( 4 );
var Child, child;
function Parent() {}
@@ -35,4 +36,4 @@
strictEqual( Child.extend, oop.extend, 'make Child extendeable' );
} );
-}( mw.mobileFrontend ) );
+}( mw.mobileFrontend, QUnit ) );
diff --git a/tests/js/test_mf-photo.js b/tests/js/test_mf-photo.js
index 8e4c7ca..a6ef485 100644
--- a/tests/js/test_mf-photo.js
+++ b/tests/js/test_mf-photo.js
@@ -1,4 +1,4 @@
-( function ( $, M ) {
+( function ( $, M, Q ) {
var photo = M.require( 'photo' ),
articles = [
@@ -36,6 +36,7 @@
} );
test( '#needsPhoto', function() {
+ Q.expect( articles.length );
var i;
for ( i = 0; i < articles.length; i++ ) {
strictEqual( photo._needsPhoto( articles[ i ][ 0 ] ), articles[
i ][ 1 ], 'article ' + i );
@@ -43,6 +44,7 @@
} );
test( 'PhotoUploadProgress', function() {
+ Q.expect( 3 );
var progressPopup = new photo._PhotoUploadProgress();
strictEqual(
progressPopup.$( '.wait' ).text(),
@@ -64,6 +66,7 @@
} );
test( 'generateFileName', function() {
+ Q.expect( 1 );
var date = new Date( 2010, 9, 15, 12, 51 ),
name = photo.generateFileName( 'Jon eating bacon next to an
armadillo', '.jpg', date );
strictEqual( name, 'Jon eating bacon next to an armadillo 2010-10-15
12-51.jpg',
@@ -71,6 +74,7 @@
} );
test( 'generateFileName test padding', function() {
+ Q.expect( 1 );
var date = new Date( 2013, 2, 1, 12, 51 ), // note 0 = january
name = photo.generateFileName( 'Tomasz eating bacon next to a
dinosaur', '.jpg', date );
strictEqual( name, 'Tomasz eating bacon next to a dinosaur 2013-03-01
12-51.jpg',
@@ -78,6 +82,7 @@
} );
test( 'generateFileName long line', function() {
+ Q.expect( 2 );
var i,
longDescription = '',
date = new Date( 2013, 2, 1, 12, 51 ), name;
@@ -91,6 +96,7 @@
} );
test( 'generateFileName with new lines', function() {
+ Q.expect( 1 );
var
description = 'One\nTwo\nThree',
date = new Date( 2013, 2, 1, 12, 51 ), name;
@@ -100,10 +106,11 @@
} );
test( 'trimUtf8String', function() {
+ Q.expect( 4 );
strictEqual( photo.trimUtf8String( 'Just a string', 20 ), 'Just a
string', 'ascii string fits' );
strictEqual( photo.trimUtf8String( 'Just a string', 10 ), 'Just a str',
'ascii string truncated' );
strictEqual( photo.trimUtf8String( 'Júst á stríng', 10 ), 'Júst á s',
'latin1 string truncated' );
strictEqual( photo.trimUtf8String( 'こんにちは', 10 ), 'こんに', 'CJK string
truncated' );
} );
-}( jQuery, mw.mobileFrontend ) );
+}( jQuery, mw.mobileFrontend, QUnit ) );
diff --git a/tests/js/test_mf-view.js b/tests/js/test_mf-view.js
index 4aa0f11..620bcc3 100644
--- a/tests/js/test_mf-view.js
+++ b/tests/js/test_mf-view.js
@@ -1,16 +1,18 @@
-( function( M, $ ) {
+( function( M, $, Q ) {
var View = M.require( 'view' );
module( 'MobileFrontend view' );
test( 'View', function() {
+ Q.expect( 2 );
var view = new View( { el: 'body' } );
ok( view.$el instanceof $, 'assign jQuery object to $el' );
strictEqual( view.$el[0].tagName.toUpperCase(), 'BODY', 'assign proper
jQuery object to $el' );
} );
test( 'View, jQuery proxy functions', function() {
+ Q.expect( 10 );
var view = new View( { el: 'body' } );
[
'append',
@@ -32,6 +34,7 @@
} );
test( 'View.extend, with el property', function() {
+ Q.expect( 1 );
var ChildView, $testEl, view;
ChildView = View.extend( {
firstHeading: function() {
@@ -46,6 +49,7 @@
} );
test( 'View.extend, with defined template', function() {
+ Q.expect( 4 );
var ChildView, view;
ChildView = View.extend( {
className: 'my-class',
@@ -66,6 +70,7 @@
} );
test( 'View.extend, initialize function', function() {
+ Q.expect( 1 );
var ChildView, view, spy = sinon.spy();
ChildView = View.extend( {
initialize: function() {
@@ -77,4 +82,4 @@
ok( spy.calledOnce, 'invoke initialize' );
} );
-}( mw.mobileFrontend, jQuery ) );
+}( mw.mobileFrontend, jQuery, QUnit ) );
diff --git a/tests/js/test_mf-watchstar.js b/tests/js/test_mf-watchstar.js
index 636268d..bbae441 100644
--- a/tests/js/test_mf-watchstar.js
+++ b/tests/js/test_mf-watchstar.js
@@ -1,4 +1,4 @@
-( function ( $, W ) {
+( function ( $, W, Q ) {
var _ajax;
module( 'MobileFrontend mf-watchlist.js', {
@@ -43,6 +43,7 @@
} );
test( 'init watched article', function() {
+ Q.expect( 2 );
var $container = $( '<div>' );
W.initWatchListIcon( $container[ 0 ], 'Spongebob' );
strictEqual( $container.find( '.watch-this-article' ).length, 1,
'button created' );
@@ -50,6 +51,7 @@
} );
test( 'init unwatched article', function() {
+ Q.expect( 2 );
var $container = $( '<div>' );
W.initWatchListIcon( $container[ 0 ], 'Popeye' );
strictEqual( $container.find( '.watch-this-article' ).length, 1,
'button created' );
@@ -57,10 +59,11 @@
} );
test( 'initWatchListIconList', function() {
+ Q.expect( 2 );
var $container = $( '<ul><li title="Popeye"><li
title="Spongebob"></ul>' );
W.initWatchListIconList( $container );
strictEqual( $container.find( '.watch-this-article' ).length, 2, '2
buttons created' );
strictEqual( $container.find( '.watch-this-article.watched' ).length,
1, 'One article is watched' );
} );
-}( jQuery, mw.mobileFrontend.require( 'watchstar' ) ) );
+}( jQuery, mw.mobileFrontend.require( 'watchstar' ), QUnit ) );
diff --git a/tests/js/test_references.js b/tests/js/test_references.js
index 7663249..b9b6a01 100644
--- a/tests/js/test_references.js
+++ b/tests/js/test_references.js
@@ -1,4 +1,4 @@
-( function( $, R ) {
+( function( $, R, Q ) {
module("MobileFrontend references.js", {
setup: function() {
@@ -10,10 +10,11 @@
});
test("Standard", function() {
+ Q.expect( 2 );
R.setupReferences( $( '#mfe-test-references' )[ 0 ] );
$("#mfe-test-references sup a").trigger("click");
strictEqual( $( '#mf-notification div h3' ).text(), '[1]' );
strictEqual( $( '#mf-notification div a' ).text(), 'test reference' );
});
-} )( jQuery, mw.mobileFrontend.require( 'references' ) );
+} )( jQuery, mw.mobileFrontend.require( 'references' ), QUnit );
diff --git a/tests/js/test_settings.js b/tests/js/test_settings.js
index d24260e..f1e9d57 100644
--- a/tests/js/test_settings.js
+++ b/tests/js/test_settings.js
@@ -1,7 +1,8 @@
-( function ( MFEB ) {
+( function ( MFEB, Q ) {
module("MobileFrontend settings.js: cookies");
test("read and write cookies", function() {
+ Q.expect( 1 );
var cookie_name = 'test_cookies_module', cookieVal;
MFEB.writeCookie(cookie_name, "yes", 400);
cookieVal = MFEB.readCookie( cookie_name );
@@ -10,6 +11,7 @@
});
test("read and write cookies with spaces", function() {
+ Q.expect( 1 );
var cookie_name = 'test_cookies_module', cookieVal;
MFEB.writeCookie(cookie_name, " yes this has spaces ", 400);
MFEB.writeCookie(cookie_name + "2", " yes this has spaces ",
400);
@@ -19,10 +21,11 @@
});
test("remove cookie via write", function() {
+ Q.expect( 1 );
var cookie_name = 'test_cookies_module', cookieVal;
MFEB.writeCookie(cookie_name, "", -1);
cookieVal = MFEB.readCookie( cookie_name );
strictEqual(cookieVal, null, "Cookie deleted");
});
-}( mw.mobileFrontend.settings ) );
+}( mw.mobileFrontend.settings, QUnit ) );
diff --git a/tests/js/test_toggle.js b/tests/js/test_toggle.js
index a17eccf..deaa445 100644
--- a/tests/js/test_toggle.js
+++ b/tests/js/test_toggle.js
@@ -1,4 +1,4 @@
-( function ( $, toggle ) {
+( function ( $, toggle, Q ) {
var $container;
function makeSections() {
@@ -24,6 +24,7 @@
});
test("wm_toggle_section", function() {
+ Q.expect( 5 );
strictEqual($("#section_1").hasClass("openSection"), true, "openSection
class present");
toggle.wm_toggle_section( '1' );
strictEqual($("#content_1").hasClass("openSection"), false, "check
content is closed on a toggle");
@@ -36,24 +37,28 @@
});
test("clicking a hash link to reveal an already open section", function() {
+ Q.expect( 2 );
strictEqual($("#section_1").hasClass("openSection"), true, "check
section is open");
toggle.wm_reveal_for_hash( 'First_Section' );
strictEqual($("#section_1").hasClass("openSection"), true, "check
section is still open");
});
test("wm_reveal_for_hash", function() {
+ Q.expect( 2 );
toggle.wm_reveal_for_hash( '#First_Section_2' );
strictEqual($("#content_1").hasClass("openSection"), true, "check
content is visible on a toggle");
strictEqual($("#section_1").hasClass("openSection"), true, "check
section is marked as open");
});
test("clicking hash links", function() {
+ Q.expect( 2 );
$( '[href=#First_Section_2]' ).trigger( 'click' );
strictEqual($("#content_1").hasClass("openSection"), true, "check
content is visible on a toggle");
strictEqual($("#section_1").hasClass("openSection"), true, "check
section marked as open");
});
test("clicking a heading toggles it", function() {
+ Q.expect( 2 );
var visibilityStart = $("#content_2").hasClass("openSection");
$( '#section_2' ).trigger( 'mousedown' );
strictEqual(visibilityStart, false, "check content is hidden at start");
@@ -75,7 +80,8 @@
});
test("close a section", function() {
+ Q.expect( 1 );
strictEqual( $( '#anchor_1' ).length, 0, 'check anchor is no longer
present' );
});
-}( jQuery, mw.mobileFrontend.require( 'toggle' ) ) );
+}( jQuery, mw.mobileFrontend.require( 'toggle' ), QUnit ) );
diff --git a/tests/js/widgets/test_progress-bar.js
b/tests/js/widgets/test_progress-bar.js
index e262865..fe3886e 100644
--- a/tests/js/widgets/test_progress-bar.js
+++ b/tests/js/widgets/test_progress-bar.js
@@ -1,13 +1,14 @@
-( function( M ) {
+( function( M, Q ) {
var ProgressBar = M.require( 'widgets/progress-bar' );
module( 'MobileFrontend ProgressBar' );
test( '#setValue', function() {
+ Q.expect( 1 );
var progressBar = new ProgressBar();
progressBar.setValue( 0.35 );
strictEqual( progressBar.$( '.value' ).css( 'width' ), '35%',
'set width to reflect value' );
} );
-}( mw.mobileFrontend, jQuery ) );
+}( mw.mobileFrontend, QUnit ) );
--
To view, visit https://gerrit.wikimedia.org/r/56322
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I545cd1520ac4b0f945b71f76479473bcebe66573
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits