Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4150194
mediawiki.api.watch.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
mediawiki.api.watch.test.js
View Options
QUnit
.
module
(
'mediawiki.api.watch'
,
(
hooks
)
=>
{
let
server
;
hooks
.
beforeEach
(
function
()
{
server
=
this
.
sandbox
.
useFakeServer
();
server
.
respondImmediately
=
true
;
}
);
QUnit
.
test
(
'.watch( string )'
,
async
(
assert
)
=>
{
server
.
respond
(
(
req
)
=>
{
// Match POST requestBody
if
(
/action=watch.*&titles=Foo(&|$)/
.
test
(
req
.
requestBody
)
)
{
req
.
respond
(
200
,
{
'Content-Type'
:
'application/json'
},
'{ "watch": [ { "title": "Foo", "watched": true, "message": "<b>Added</b>" } ] }'
);
}
}
);
const
item
=
await
new
mw
.
Api
().
watch
(
'Foo'
);
assert
.
strictEqual
(
item
.
title
,
'Foo'
);
}
);
// Ensure we don't mistake a single item array for a single item and vice versa.
// The query parameter in request is the same either way (separated by pipe).
QUnit
.
test
(
'.watch( Array ) - single'
,
async
(
assert
)
=>
{
server
.
respond
(
(
req
)
=>
{
// Match POST requestBody
if
(
/action=watch.*&titles=Foo(&|$)/
.
test
(
req
.
requestBody
)
)
{
req
.
respond
(
200
,
{
'Content-Type'
:
'application/json'
},
'{ "watch": [ { "title": "Foo", "watched": true, "message": "<b>Added</b>" } ] }'
);
}
}
);
const
items
=
await
new
mw
.
Api
().
watch
(
[
'Foo'
]
);
assert
.
strictEqual
(
items
[
0
].
title
,
'Foo'
);
}
);
QUnit
.
test
(
'.watch( Array ) - multi'
,
async
(
assert
)
=>
{
server
.
respond
(
(
req
)
=>
{
// Match POST requestBody
if
(
/action=watch.*&titles=Foo%7CBar/
.
test
(
req
.
requestBody
)
)
{
req
.
respond
(
200
,
{
'Content-Type'
:
'application/json'
},
'{ "watch": [ '
+
'{ "title": "Foo", "watched": true, "message": "<b>Added</b>" },'
+
'{ "title": "Bar", "watched": true, "message": "<b>Added</b>" }'
+
'] }'
);
}
}
);
const
items
=
await
new
mw
.
Api
().
watch
(
[
'Foo'
,
'Bar'
]
);
assert
.
strictEqual
(
items
[
0
].
title
,
'Foo'
);
assert
.
strictEqual
(
items
[
1
].
title
,
'Bar'
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Aug 19 2026, 19:28 (6 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
36/6f/8dfa8d676739d43783ac83dad4f9
Default Alt Text
mediawiki.api.watch.test.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment