Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5990760
WatchList.test.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
WatchList.test.js
View Options
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
Details
Attached
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)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment