Page MenuHomeWickedGov Phorge

WatchList.test.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

WatchList.test.js

const
jQuery = require( '../utils/jQuery' ),
dom = require( '../utils/dom' ),
mediaWiki = require( '../utils/mw' ),
oo = require( '../utils/oo' ),
sinon = require( 'sinon' ),
mustache = require( '../utils/mustache' );
let
WatchList,
sandbox;
QUnit.module( 'MobileFrontend WatchList.js', {
beforeEach: function () {
sandbox = sinon.sandbox.create();
dom.setUp( sandbox, global );
jQuery.setUp( sandbox, global );
oo.setUp( sandbox, global );
mediaWiki.setUp( sandbox, global );
mustache.setUp( sandbox, global );
sandbox.stub( global.mw.Title, 'newFromText' ).returns(
{ getUrl: function () {} }
);
sandbox.stub( mw.user, 'isAnon' ).returns( false );
sandbox.stub( mw.loader, 'require' ).withArgs( 'mediawiki.page.watch.ajax' ).returns( {
watchstar: () => {}
} );
WatchList = require( '../../../src/mobile.special.watchlist.scripts/WatchList' );
},
afterEach: function () {
jQuery.tearDown();
sandbox.restore();
}
} );
QUnit.test( 'In watched mode', function ( assert ) {
const
stub = {
get: sandbox.stub()
},
pl = new WatchList( {
eventBus: {
on: function () {},
off: function () {}
},
api: stub,
pages: [
{ title: 'Title 30' },
{ title: 'Title 50' },
{
title: 'Title 60',
watched: true
}
]
} );
// Avoid API requests due to scroll events (https://phabricator.wikimedia.org/T116258)
pl.scrollEndEventEmitter.disable();
assert.true( stub.get.notCalled, 'Callback avoided' );
assert.strictEqual( pl.$el.find( '.watch-this-article' ).length, 3, '3 articles have watch stars...' );
assert.strictEqual( pl.$el.find( '.watched' ).length, 3, '...and all are marked as watched.' );
} );

File Metadata

Mime Type
text/plain
Expires
Sun, Oct 4, 01:38 (3 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9f/b7/90323ea4e958a2b55981cbf38834
Default Alt Text
WatchList.test.js (1 KB)

Event Timeline